return-negative-one-from-write.html 1.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<html>
    <head>
        <script src="../fast/js/resources/js-test-pre.js"></script>
    </head>
    <body>
        <p id="description"></p>
        <div id="console"></div>

        <script>
            var newStreamCalled = false;
            var destroyStreamCalled = false;

            function main() {
14
                if (!window.testRunner) {
15 16 17
                    debug("This test can only run from within DumpRenderTree, because it requires TestNetscapePlugin.\n");
                    return;
                }
18
                testRunner.waitUntilDone();
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
            }

            main();

            function streamStarted() {
                shouldBeFalse('newStreamCalled');
                newStreamCalled = true;
            }

            function streamDestroyed(reason) { 
                window.reason = reason;

                shouldBeTrue('newStreamCalled')
                shouldBe('reason', '1');

                debug('<br><span class="pass">TEST COMPLETE</span>');

36
                testRunner.notifyDone();
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
            }
        </script>

        <embed
            type="application/x-webkit-test-netscape"
            onStreamLoad="streamStarted()"
            onStreamDestroy="streamDestroyed"
            id="plugin">
    </body>
    <script>
        description("This tests that NPP_DestroyStream is called with NPRES_NETWORK_ERR not called if a plug-in returns -1 its NPP_Write callback.");

        var plugin = document.getElementById("plugin");

        plugin.returnNegativeOneFromWrite = true;
        shouldBeTrue("plugin.returnNegativeOneFromWrite");

        plugin.getURLNotify("data:text/html,Test", null, "callback");
    </script>
</html>