Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
2010-09-09 Tony Gentilcore <tonyg@chromium.org>
Reviewed by Adam Barth. Support <script async> as specified by HTML5 https://bugs.webkit.org/show_bug.cgi?id=45310 * fast/dom/Document/readystate.html: Dynamically inserted scripts now block the load event like in FF4. So move the finishJSTest call to load. * fast/dom/Document/readystate-expected.txt: Dynamically inserted script now runs before load during "interactive" phase. * fast/dom/HTMLScriptElement/async-inline-script-expected.txt: Added. * fast/dom/HTMLScriptElement/async-inline-script.html: Added. The async attribute doesn't apply to inline scripts, so check that they execute in order. * fast/dom/HTMLScriptElement/async-onbeforeload-expected.txt: Added. * fast/dom/HTMLScriptElement/async-onbeforeload.html: Added. Check that onbeforeload events fire synchronously and that they may be cancelled. * fast/dom/HTMLScriptElement/async-write-expected.txt: Added. * fast/dom/HTMLScriptElement/async-write.html: Added. Check that writes from async scripts are neutralized. * fast/dom/HTMLScriptElement/resources/async.js: Added. * http/tests/misc/async-and-defer-script-expected.txt: Added. * http/tests/misc/async-and-defer-script.html: Added. The async attributes takes precendence over the defer attribute. Check that a script which has both async and defer acts as async by ensuring it loads after DOMContentLoaded. A deferred scripts would block DCL. * http/tests/misc/resources/async-script.js: Added. * http/tests/misc/resources/slow-async-script.cgi: Added. * http/tests/misc/script-async-expected.txt: Added. * http/tests/misc/script-async.html: Added. Test general execution order of deferred scripts. The test checks for multiple valid orders since it is indeterminate. 2010-09-09 Tony Gentilcore <tonyg@chromium.org> Reviewed by Adam Barth. Support <script async> as specified by HTML5 https://bugs.webkit.org/show_bug.cgi?id=45310 Tests: fast/dom/HTMLScriptElement/async-inline-script.html fast/dom/HTMLScriptElement/async-onbeforeload.html fast/dom/HTMLScriptElement/async-write.html http/tests/misc/async-and-defer-script.html http/tests/misc/script-async.html * dom/AsyncScriptRunner.cpp: (WebCore::AsyncScriptRunner::AsyncScriptRunner): (WebCore::AsyncScriptRunner::~AsyncScriptRunner): (WebCore::AsyncScriptRunner::executeScriptSoon): Increment the delay count when a task to execute scripts is queued up. (WebCore::AsyncScriptRunner::timerFired): decrementLoadEventDelayCount handles calling checkCompleted(). * dom/AsyncScriptRunner.h: (WebCore::AsyncScriptRunner::create): * dom/Document.cpp: (WebCore::Document::Document): * dom/ScriptElement.cpp: (WebCore::ScriptElement::insertedIntoDocument): Treats async scripts just like a dynamically inserted script element rather than a parser inserted one. * html/parser/HTMLScriptRunner.cpp: (WebCore::HTMLScriptRunner::runScript): Canonical link: https://commits.webkit.org/57899@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@67163 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
219 additions
and 13 deletions.
- +26 −0 LayoutTests/ChangeLog
- +1 −1 LayoutTests/fast/dom/Document/readystate-expected.txt
- +2 −3 LayoutTests/fast/dom/Document/readystate.html
- +4 −0 LayoutTests/fast/dom/HTMLScriptElement/async-inline-script-expected.txt
- +17 −0 LayoutTests/fast/dom/HTMLScriptElement/async-inline-script.html
- +10 −0 LayoutTests/fast/dom/HTMLScriptElement/async-onbeforeload-expected.txt
- +17 −0 LayoutTests/fast/dom/HTMLScriptElement/async-onbeforeload.html
- +1 −0 LayoutTests/fast/dom/HTMLScriptElement/async-write-expected.txt
- +6 −0 LayoutTests/fast/dom/HTMLScriptElement/async-write.html
- +1 −0 LayoutTests/fast/dom/HTMLScriptElement/resources/async.js
- +8 −0 LayoutTests/http/tests/misc/async-and-defer-script-expected.txt
- +20 −0 LayoutTests/http/tests/misc/async-and-defer-script.html
- +1 −0 LayoutTests/http/tests/misc/resources/async-script.js
- +6 −0 LayoutTests/http/tests/misc/resources/slow-async-script.cgi
- +2 −0 LayoutTests/http/tests/misc/script-async-expected.txt
- +50 −0 LayoutTests/http/tests/misc/script-async.html
- +27 −0 WebCore/ChangeLog
- +11 −4 WebCore/dom/AsyncScriptRunner.cpp
- +4 −2 WebCore/dom/AsyncScriptRunner.h
- +1 −1 WebCore/dom/Document.cpp
- +1 −1 WebCore/dom/ScriptElement.cpp
- +3 −1 WebCore/html/parser/HTMLScriptRunner.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,4 @@ | ||
Checks that inline scripts are not async. | ||
1 | ||
2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../../js/resources/js-test-style.css"> | ||
<script src="../../js/resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
Checks that inline scripts are not async. | ||
<div id="console"></div> | ||
<script async> | ||
debug(1); | ||
</script> | ||
<script> | ||
debug(2); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,10 @@ | ||
Checks that async scripts fire onbeforeload immediately and that it is cancellable. | ||
cancelled onbeforeload async | ||
onbeforeload async | ||
onbeforeload external | ||
async | ||
load | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../../js/resources/js-test-style.css"> | ||
<script src="../../js/resources/js-test-pre.js"></script> | ||
</head> | ||
<body onload="debug('load');finishJSTest();"> | ||
Checks that async scripts fire onbeforeload immediately and that it is cancellable. | ||
<div id="console"></div> | ||
<script>var jsTestIsAsync = true;</script> | ||
<script src="resources/shouldnotexecute.js" onbeforeload="debug('cancelled onbeforeload async'); return false;" async></script> | ||
<script src="resources/async.js" onbeforeload="debug('onbeforeload async'); return true;" async></script> | ||
<script src="data:text/javascript," onbeforeload="debug('onbeforeload external'); return true;"></script> | ||
<script>var successfullyParsed = true;</script> | ||
<script src="../../js/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1 @@ | ||
PASS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,6 @@ | ||
<script> | ||
if (window.layoutTestController) | ||
layoutTestController.dumpAsText(); | ||
</script> | ||
PASS | ||
<script async="ASYNC" src="data:text/javascript,document.write('FAIL');"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1 @@ | ||
debug("async"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
Checks that the async attribute takes precendence over defer. | ||
DOMContentLoaded | ||
slowAsync | ||
load | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../../js-tests-resources/js-test-style.css"> | ||
<script src="../../js-test-resources/js-test-pre.js"></script> | ||
</head> | ||
<body onload="debug('load');finishJSTest();"> | ||
Checks that the async attribute takes precendence over defer. | ||
<div id="console"></div> | ||
<script> | ||
var jsTestIsAsync = true; | ||
document.addEventListener("DOMContentLoaded", function() { | ||
debug("DOMContentLoaded"); | ||
}, false); | ||
var successfullyParsed = true; | ||
</script> | ||
<script defer async src="http://127.0.0.1:8000/misc/resources/slow-async-script.cgi"></script> | ||
<script src="../../js-test-resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1 @@ | ||
debug("async"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/perl -w | ||
|
||
print "Content-type: text/javascript\n\n"; | ||
sleep(1.0); | ||
print "debug('slowAsync');\n"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,2 @@ | ||
This tests for proper execution order of scripts with the async attribute https://bugs.webkit.org/show_bug.cgi?id=20710. | ||
PASS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<link rel="stylesheet" href="../../js-test-resources/js-test-style.css"> | ||
<script src="../../js-test-resources/js-test-pre.js"></script> | ||
</head> | ||
<body onload="test()"> | ||
This tests for proper execution order of scripts with the async attribute <a href="https://bugs.webkit.org/show_bug.cgi?id=20710">https://bugs.webkit.org/show_bug.cgi?id=20710</a>.<hr> | ||
<div id="console"></div> | ||
<script type="text/javascript"> | ||
var jsTestIsAsync = true; | ||
|
||
function debug(msg) | ||
{ | ||
if (!window.status_) | ||
window.status_ = ''; | ||
window.status_ += ' ' + msg + ' '; | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", function() { | ||
debug('DOMContentLoaded'); | ||
}, false); | ||
|
||
function test() | ||
{ | ||
var expectedA = " async external inline DOMContentLoaded slowAsync "; | ||
var expectedB = " external async inline DOMContentLoaded slowAsync "; | ||
var expectedC = " external inline async DOMContentLoaded slowAsync "; | ||
var expectedD = " external inline DOMContentLoaded async slowAsync "; | ||
var results = "PASS"; | ||
if (window.status_ != expectedA && window.status_ != expectedB && window.status_ != expectedC && window.status_ != expectedD) | ||
results = "FAIL: Expected one of '" + expectedA + "' || '" + expectedB + "' || '" + expectedC + "' || '" + expectedD + "', Actual='" + window.status_ + "'"; | ||
document.getElementById("console").innerHTML = results; | ||
finishJSTest(); | ||
} | ||
|
||
var successfullyParsed = true; | ||
</script> | ||
<script src="http://127.0.0.1:8000/misc/resources/slow-async-script.cgi" async="ASYNC"></script> | ||
<script src="http://127.0.0.1:8000/misc/resources/async-script.js" async="ASYNC"></script> | ||
<script src="http://127.0.0.1:8000/misc/resources/external-script.js"></script> | ||
<script> | ||
debug("inline"); | ||
</script> | ||
<script src="../../js-test-resources/js-test-post.js"></script> | ||
</body> | ||
</html> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters