content/base/test/test_bug587931.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=587931
     5 -->
     6 <head>
     7   <title>Test for Bug 587931</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=587931">Mozilla Bug 587931</a>
    13 <pre id="test">
    14 <script type="application/javascript">
    15 /** Test for Bug 587931 **/
    16 SimpleTest.waitForExplicitFinish();
    17 var afterCount = 0;
    18 var lastBeforeExecute = null;
    19 var expectedCurrentScriptInAfterScriptExecute = null;
    20 function verifyScript(n) {
    21   var curr = document.currentScript;
    22   is(curr, document.getElementById(n), "correct script (" + n + ")");
    23   is(lastBeforeExecute, curr, "correct beforescript (" + n + ")");
    24   document.addEventListener("afterscriptexecute", function(event) {
    25     afterCount++;
    26     lastBeforeExecute = null;
    27     is(event.target, curr, "correct afterscript (" + n + ")");
    28     is(document.currentScript, expectedCurrentScriptInAfterScriptExecute,
    29        "document.currentScript in afterscriptexecute(" + n + ")");
    30     document.removeEventListener("afterscriptexecute", arguments.callee, false);
    31   }, false);
    32 }
    33 document.onbeforescriptexecute = function(event) {
    34   lastBeforeExecute = event.target;
    35 };
    37 window.addEventListener("load", function() {
    38   is(afterCount, 4, "correct number of afterscriptexecute");
    39   SimpleTest.finish();
    40 }, false);
    41 </script>
    42 </pre>
    43 <!-- Test parser inserted scripts -->
    44 <script id="parse-inline">
    45 verifyScript("parse-inline");
    46 </script>
    47 <script id="parse-ext" src="data:text/plain,verifyScript('parse-ext');"></script>
    49 <!-- Test DOM inserted scripts -->
    50 <script>
    51 var s = document.createElement("script");
    52 s.textContent = "verifyScript('dom-inline');";
    53 s.id = "dom-inline";
    54 expectedCurrentScriptInAfterScriptExecute = document.currentScript;
    55 document.body.appendChild(s);
    56 expectedCurrentScriptInAfterScriptExecute = null;
    58 s = document.createElement("script");
    59 s.src = "data:text/plain,verifyScript('dom-ext');";
    60 s.id = "dom-ext";
    61 document.body.appendChild(s);
    62 </script>
    64 <!-- Test cancel using beforescriptexecute -->
    65 <script onbeforescriptexecute="return false;"
    66         onafterescriptexecute="window.firedAfterScriptExecuteForCancel = true;">
    67 ok(false, "should have been canceled");
    68 </script>
    69 <script>
    70 isnot(window.firedAfterScriptExecuteForCancel, true, "onafterscriptexecute executed");
    71 </script>
    73 <!-- Test cancel using beforescriptexecute for external -->
    74 <script onbeforescriptexecute="return false;"
    75         onafterescriptexecute="window.extFiredAfterScriptExecuteForCancel = true;"
    76         onload="window.extFiredLoadForCancel = true;"
    77         src="data:text/plain,ok(false, 'should have been canceled');">
    78 </script>
    79 <script>
    80 isnot(window.extFiredAfterScriptExecuteForCancel, true, "onafterscriptexecute executed");
    81 is(extFiredLoadForCancel, true, "onload executed");
    82 </script>
    84 <!-- Test that all events fire -->
    85 <script onbeforescriptexecute="window.beforeDidExecute = true;"
    86         onafterscriptexecute="window.afterDidExecute = true;"
    87         onload="window.loadDidExecute = true"
    88         onerror="window.errorDidExecute = true"
    89         src="data:text/plain,
    90 is(window.beforeDidExecute, true, 'onbeforescriptexecute executed');
    91 isnot(window.afterDidExecute, true, 'onafterscriptexecute executed');
    92 isnot(window.loadDidExecute, true, 'onload executed');
    93 isnot(window.errorDidExecute, true, 'onerror executed');
    94 ">
    95 </script>
    96 <script>
    97 is(afterDidExecute, true, "onafterscriptexecute executed");
    98 is(loadDidExecute, true, "onload executed");
    99 isnot(window.errorDidExecute, true, "onerror executed");
   100 </script>
   101 </body>
   102 </html>

mercurial