Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=602838 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 602838</title> |
michael@0 | 8 | <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602838">Mozilla Bug 602838</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | |
michael@0 | 17 | </div> |
michael@0 | 18 | <pre id="test"> |
michael@0 | 19 | <script id=withasync async></script> |
michael@0 | 20 | <script id=withoutasync></script> |
michael@0 | 21 | <script class="testbody" type="text/javascript"> |
michael@0 | 22 | |
michael@0 | 23 | /** Test for Bug 602838 **/ |
michael@0 | 24 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 25 | var firstRan = false; |
michael@0 | 26 | var asyncRan = false; |
michael@0 | 27 | |
michael@0 | 28 | var withoutasync = document.getElementById("withoutasync"); |
michael@0 | 29 | ok(withoutasync.async, "When a script loses parser-insertedness, it should become async."); |
michael@0 | 30 | |
michael@0 | 31 | var withasync = document.getElementById("withasync"); |
michael@0 | 32 | ok(withasync.async, "A script with the async content attribute should have the DOM attribute reporting true."); |
michael@0 | 33 | withasync.removeAttribute("async"); |
michael@0 | 34 | ok(!withasync.async, "Should be able to remove asyncness from a script that had the async content attribute when losing parser-insertedness by removing the content attribute."); |
michael@0 | 35 | |
michael@0 | 36 | var s = document.createElement("script"); |
michael@0 | 37 | ok(s.async, "Script-created scripts should default to .async=true"); |
michael@0 | 38 | ok(!s.hasAttribute("async"), "Script-created scripts should not have the async content attribute by default."); |
michael@0 | 39 | s.removeAttribute("async"); |
michael@0 | 40 | ok(s.async, "Removing a non-existing content-attribute should not have an effect on the forced async DOM property."); |
michael@0 | 41 | s.setAttribute("async", ""); |
michael@0 | 42 | ok(s.async, "The async DOM property should still be true."); |
michael@0 | 43 | s.removeAttribute("async"); |
michael@0 | 44 | ok(!s.async, "When a previously present async content attribute is removed, the DOM property should become false."); |
michael@0 | 45 | s.src = "script_bug602838.sjs"; |
michael@0 | 46 | document.body.appendChild(s); |
michael@0 | 47 | |
michael@0 | 48 | s = document.createElement("script"); |
michael@0 | 49 | s.src = "data:text/javascript,ok(firstRan, 'The first script should have run'); SimpleTest.finish();"; |
michael@0 | 50 | s.async = false; |
michael@0 | 51 | ok(!s.async, "Setting the async DOM property to false should turned of forcing async to true."); |
michael@0 | 52 | document.body.appendChild(s); |
michael@0 | 53 | |
michael@0 | 54 | function unblock() { |
michael@0 | 55 | var xhr = new XMLHttpRequest(); |
michael@0 | 56 | xhr.open("GET", "script_bug602838.sjs?unblock"); |
michael@0 | 57 | xhr.send(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | s = document.createElement("script"); |
michael@0 | 61 | s.src = "data:text/javascript,ok(!firstRan, 'Non-async should not have run yet.'); asyncRan = true; unblock();"; |
michael@0 | 62 | document.body.appendChild(s); |
michael@0 | 63 | |
michael@0 | 64 | </script> |
michael@0 | 65 | </pre> |
michael@0 | 66 | </body> |
michael@0 | 67 | </html> |
michael@0 | 68 |