summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/plugins/script-object-invoke.html
blob: f787303dde26c4f9b916586a8bd7680d1d22056c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<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>