| <html> | |
| <script> | |
| // A simple script object with a member function that takes | |
| // an NPObject as an argument | |
| FactoryFunction = function() { | |
| var TestObject = function() { | |
| }; | |
| TestObject.prototype.createObject = function(plugin) { | |
| var new_object = plugin.testCloneObject(); | |
| return new_object; | |
| }; | |
| var s = new TestObject(); | |
| return s; | |
| }; | |
| function new_script_object() { | |
| return FactoryFunction(); | |
| } | |
| function runTest() | |
| { | |
| if (window.testRunner) | |
| testRunner.dumpAsText(); | |
| var plugin = document.getElementById("testPlugin"); | |
| var returned_object = plugin.testScriptObjectInvoke("new_script_object", "createObject"); | |
| // Make sure the cloned object outlives the plugin. | |
| /* FIXME(joshia): Enable this and fix the NPObject cleanup so that | |
| it works in single process mode. | |
| plugin.parentNode.removeChild(plugin); | |
| try { | |
| returned_object.property; | |
| } catch (e) { | |
| if (e instanceof ReferenceError) | |
| document.getElementById("result").innerHTML = "SUCCESS"; | |
| } | |
| */ | |
| document.getElementById("result").innerHTML = "SUCCESS"; | |
| } | |
| </script> | |
| <body onload="runTest();"> | |
| <pre> | |
| Test proper tracking of script NPObjects | |
| Test 1: Ensure that script NPObjects are properly tracked (i.e. added to | |
| the live objects map in V8). | |
| Test 2: Test tracking of derived NPObjects by invoking a method on a | |
| script object and passing it an internally created NPObject. | |
| <div id="result">FAILURE</div> | |
| <embed id="testPlugin" type="application/x-webkit-test-netscape" width="200" height="200"></embed> | |
| </body> | |
| </html> |