4 https://bugzilla.mozilla.org/show_bug.cgi?id=602838
7 <title>Test for Bug
602838</title>
8 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=602838">Mozilla Bug
602838</a>
15 <div id=
"content" style=
"display: none">
19 <script id=withasync async
></script>
20 <script id=withoutasync
></script>
21 <script class=
"testbody" type=
"text/javascript">
23 /** Test for Bug
602838 **/
24 SimpleTest.waitForExplicitFinish();
28 var withoutasync = document.getElementById(
"withoutasync");
29 ok(withoutasync.async,
"When a script loses parser-insertedness, it should become async.");
31 var withasync = document.getElementById(
"withasync");
32 ok(withasync.async,
"A script with the async content attribute should have the DOM attribute reporting true.");
33 withasync.removeAttribute(
"async");
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.");
36 var s = document.createElement(
"script");
37 ok(s.async,
"Script-created scripts should default to .async=true");
38 ok(!s.hasAttribute(
"async"),
"Script-created scripts should not have the async content attribute by default.");
39 s.removeAttribute(
"async");
40 ok(s.async,
"Removing a non-existing content-attribute should not have an effect on the forced async DOM property.");
41 s.setAttribute(
"async",
"");
42 ok(s.async,
"The async DOM property should still be true.");
43 s.removeAttribute(
"async");
44 ok(!s.async,
"When a previously present async content attribute is removed, the DOM property should become false.");
45 s.src =
"script_bug602838.sjs";
46 document.body.appendChild(s);
48 s = document.createElement(
"script");
49 s.src =
"data:text/javascript,ok(firstRan, 'The first script should have run'); SimpleTest.finish();";
51 ok(!s.async,
"Setting the async DOM property to false should turned of forcing async to true.");
52 document.body.appendChild(s);
55 var xhr = new XMLHttpRequest();
56 xhr.open(
"GET",
"script_bug602838.sjs?unblock");
60 s = document.createElement(
"script");
61 s.src =
"data:text/javascript,ok(!firstRan, 'Non-async should not have run yet.'); asyncRan = true; unblock();";
62 document.body.appendChild(s);