summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/plugins/get-targeted-javascript-url.html
blob: b32e9886d403574c86f3a4875911805003c8ff97 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
    <script>
        addEventListener('load', startTest, false);
        var noReturnValueFunctionCalled = false;
        var returnValueFunctionCalled = false;
        var noReturnValueReason = -1;
        var returnValueReason = -1;

        function startTest() {
            if (window.testRunner) {
                testRunner.dumpAsText();
                testRunner.waitUntilDone();
            }

            var plugin = document.getElementsByTagName('embed')[0];
            plugin.getURLNotify('javascript:noReturnValueFunction()', '_self', 'noReturnValueURLNotify');
            plugin.getURLNotify('javascript:returnValueFunction()', '_self', 'returnValueURLNotify');

            // The javascript: URLs will be evaluated asynchronously. Since we don't expect a
            // callback when the evaluation is complete, we have to use a lame timeout to give
            // the callback time to be evaluated.
            setTimeout(finishTest, 250);
        }

        function finishTest() {
            if (!noReturnValueFunctionCalled)
                log('FAIL: noReturnValueFunction was not called');
            else if (noReturnValueReason !== -1 && noReturnValueReason !== 0)
                log('FAIL (no return value): NPP_URLNotify called with unexpected reason ' + noReturnValueReason);
            else
                log('SUCCESS (no return value): NPP_URLNotify was not called, or was called with a reason of NPRES_DONE');

            if (!returnValueFunctionCalled)
                log('FAIL: returnValueFunction was not called');
            else if (returnValueReason !== -1 && returnValueReason !== 0)
                log('FAIL (return value): NPP_URLNotify called with unexpected reason ' + returnValueReason);
            else
                log('SUCCESS (return value): NPP_URLNotify was not called, or was called with a reason of NPRES_DONE');

            if (window.testRunner)
                testRunner.notifyDone();
        }

        function log(msg) {
            document.getElementById('log').appendChild(document.createTextNode(msg + '\n'));
        }

        function noReturnValueFunction() {
            noReturnValueFunctionCalled = true;
        }

        function returnValueFunction() {
            returnValueFunctionCalled = true;
            return 'foo';
        }

        function noReturnValueURLNotify(reason) {
            noReturnValueReason = reason;
        }

        function returnValueURLNotify(reason) {
            returnValueReason = reason;
        }
    </script>
</head>
<body>
    <embed type="application/x-webkit-test-netscape"></embed>
    <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=60568">Bug 60568: REGRESSION (WebKit2): Flash plugin doesn't appear on a hanes.com page</a>.</p>
    <pre id="log"></pre>
</body>
</html>