Changeset 64674 in webkit
- Timestamp:
- Aug 4, 2010 1:39:24 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 25 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r64668 r64674 1 2010-08-04 Tony Gentilcore <tonyg@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 LayoutTests for <script defer> as specified by HTML5 6 https://bugs.webkit.org/show_bug.cgi?id=40934 7 8 * fast/dom/HTMLScriptElement/defer-double-defer-write-expected.txt: Added. 9 * fast/dom/HTMLScriptElement/defer-double-defer-write.html: Added. Tests for tricky ordering and reentrancy by doing a double write of defered scripts. 10 * fast/dom/HTMLScriptElement/defer-double-write-expected.txt: Copied from LayoutTests/fast/tokenizer/write-before-load-expected.txt. 11 * fast/dom/HTMLScriptElement/defer-double-write.html: Added. Tests for tricky ordering and reentrancy by doing a double write of inline scripts. 12 * fast/dom/HTMLScriptElement/defer-inline-script-expected.txt: Added. 13 * fast/dom/HTMLScriptElement/defer-inline-script.html: Added. Tests that the defer attribute is ignored on inline script blocks. 14 * fast/dom/HTMLScriptElement/defer-onbeforeload-expected.txt: Added. 15 * fast/dom/HTMLScriptElement/defer-onbeforeload.html: Added. Tests that onbeforeload fires immediately when a deferred script is encounted. Also tests that it can be cancelled. 16 * fast/dom/HTMLScriptElement/defer-script-invalid-url-expected.txt: Added. 17 * fast/dom/HTMLScriptElement/defer-script-invalid-url.html: Added. Tests that invalid URLs are ignored and subsequent scripts are still executed. 18 * fast/dom/HTMLScriptElement/resources/defer.js: Added. 19 * fast/dom/HTMLScriptElement/resources/external.js: Added. 20 * fast/dom/HTMLScriptElement/resources/shouldnotexecute.js: Added. 21 * http/tests/misc/resources/defer-script.js: Added. 22 * http/tests/misc/resources/external-script.js: Added. 23 * http/tests/misc/resources/script-debug-body-background.js: Added. 24 * http/tests/misc/resources/script-write-slow-stylesheet.js: Added. 25 * http/tests/misc/resources/slow-defer-script.cgi: Added. 26 * http/tests/misc/resources/slow-stylesheet.cgi: Added. 27 * http/tests/misc/script-defer-after-slow-stylesheet-expected.txt: Added. 28 * http/tests/misc/script-defer-after-slow-stylesheet.html: Added. Tests stylesheet blocking behavior. 29 * http/tests/misc/script-defer-expected.txt: Added. 30 * http/tests/misc/script-defer-write-slow-stylesheet-expected.txt: Added. 31 * http/tests/misc/script-defer-write-slow-stylesheet.html: Added. Tests stylesheet blocking behavior with a slow stylesheet. 32 * http/tests/misc/script-defer.html: Added. Tests basic functionality and ordering. 33 1 34 2010-08-04 François Sausset <sausset@gmail.com> 2 35 -
trunk/WebCore/ChangeLog
r64672 r64674 1 2010-08-04 Tony Gentilcore <tonyg@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Support <script defer> as specified by HTML5 6 https://bugs.webkit.org/show_bug.cgi?id=40934 7 8 See: http://dev.w3.org/html5/spec/Overview.html#the-end 9 10 Tests: fast/dom/HTMLScriptElement/defer-double-defer-write.html 11 fast/dom/HTMLScriptElement/defer-double-write.html 12 fast/dom/HTMLScriptElement/defer-inline-script.html 13 fast/dom/HTMLScriptElement/defer-onbeforeload.html 14 fast/dom/HTMLScriptElement/defer-script-invalid-url.html 15 http/tests/misc/script-defer-after-slow-stylesheet.html 16 http/tests/misc/script-defer-write-slow-stylesheet.html 17 http/tests/misc/script-defer.html 18 19 * html/HTMLDocumentParser.cpp: 20 (WebCore::HTMLDocumentParser::attemptToEnd): 21 (WebCore::HTMLDocumentParser::endIfDelayed): 22 (WebCore::HTMLDocumentParser::executeScriptsWaitingForParsingAndEnd): 23 * html/HTMLDocumentParser.h: 24 * html/HTMLScriptRunner.cpp: 25 (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing): 26 (WebCore::HTMLScriptRunner::requestScript): 27 (WebCore::HTMLScriptRunner::requestParsingBlockingScript): 28 (WebCore::HTMLScriptRunner::requestDeferredScript): 29 (WebCore::HTMLScriptRunner::runScript): 30 * html/HTMLScriptRunner.h: 31 (WebCore::HTMLScriptRunner::PendingScript::PendingScript): 32 (WebCore::HTMLScriptRunner::PendingScript::operator=): 33 1 34 2010-08-04 Kevin Ollivier <kevino@theolliviers.com> 2 35 -
trunk/WebCore/html/HTMLDocumentParser.cpp
r64638 r64674 282 282 return; 283 283 } 284 e nd();284 executeScriptsWaitingForParsingAndEnd(); 285 285 } 286 286 … … 291 291 292 292 m_endWasDelayed = false; 293 executeScriptsWaitingForParsingAndEnd(); 294 } 295 296 void HTMLDocumentParser::executeScriptsWaitingForParsingAndEnd() 297 { 298 if (m_scriptRunner) { 299 bool continueParsing = m_scriptRunner->executeScriptsWaitingForParsing(); 300 if (!continueParsing) { 301 m_treeBuilder->setPaused(true); 302 m_endWasDelayed = true; 303 return; 304 } 305 } 293 306 end(); 294 307 } -
trunk/WebCore/html/HTMLDocumentParser.h
r63998 r64674 106 106 void attemptToEnd(); 107 107 void endIfDelayed(); 108 void executeScriptsWaitingForParsingAndEnd(); 108 109 void end(); 109 110 -
trunk/WebCore/html/HTMLScriptRunner.cpp
r63998 r64674 229 229 } 230 230 231 void HTMLScriptRunner::requestScript(Element* script) 232 { 233 ASSERT(!m_parsingBlockingScript.element); 234 AtomicString srcValue = script->getAttribute(srcAttr); 235 // Allow the host to disllow script loads (using the XSSAuditor, etc.) 231 bool HTMLScriptRunner::executeScriptsWaitingForParsing() 232 { 233 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { 234 ASSERT(!haveParsingBlockingScript()); 235 m_parsingBlockingScript = m_scriptsToExecuteAfterParsing.takeFirst(); 236 ASSERT(m_parsingBlockingScript.cachedScript()); 237 if (!m_parsingBlockingScript.cachedScript()->isLoaded()) { 238 watchForLoad(m_parsingBlockingScript); 239 return false; 240 } 241 if (!executeParsingBlockingScripts()) 242 return false; 243 } 244 245 return m_scriptsToExecuteAfterParsing.isEmpty(); 246 } 247 248 bool HTMLScriptRunner::requestScript(PendingScript& pendingScript, Element* scriptElement) 249 { 250 ASSERT(!pendingScript.element); 251 const AtomicString& srcValue = scriptElement->getAttribute(srcAttr); 236 252 if (!m_host->shouldLoadExternalScriptFromSrc(srcValue)) 237 return ;253 return false; 238 254 // FIXME: We need to resolve the url relative to the element. 239 if (!script ->dispatchBeforeLoadEvent(srcValue))240 return ;241 m_parsingBlockingScript.element = script;255 if (!scriptElement->dispatchBeforeLoadEvent(srcValue)) 256 return false; 257 pendingScript.element = scriptElement; 242 258 // This should correctly return 0 for empty or invalid srcValues. 243 CachedScript* cachedScript = m_document->docLoader()->requestScript(srcValue, toScriptElement(script )->scriptCharset());259 CachedScript* cachedScript = m_document->docLoader()->requestScript(srcValue, toScriptElement(scriptElement)->scriptCharset()); 244 260 if (!cachedScript) { 245 261 notImplemented(); // Dispatch error event. 246 return; 247 } 248 249 m_parsingBlockingScript.setCachedScript(cachedScript); 262 return false; 263 } 264 265 pendingScript.setCachedScript(cachedScript); 266 return true; 267 } 268 269 void HTMLScriptRunner::requestParsingBlockingScript(Element* scriptElement) 270 { 271 if (!requestScript(m_parsingBlockingScript, scriptElement)) 272 return; 273 274 ASSERT(m_parsingBlockingScript.cachedScript()); 250 275 251 276 // We only care about a load callback if cachedScript is not already … … 256 281 } 257 282 283 void HTMLScriptRunner::requestDeferredScript(Element* scriptElement) 284 { 285 PendingScript pendingScript; 286 if (!requestScript(pendingScript, scriptElement)) 287 return; 288 289 ASSERT(pendingScript.cachedScript()); 290 m_scriptsToExecuteAfterParsing.append(pendingScript); 291 } 292 258 293 // This method is meant to match the HTML5 definition of "running a script" 259 294 // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#running-a-script … … 268 303 269 304 if (script->hasAttribute(srcAttr)) { 270 // FIXME: Handle defer and async 271 requestScript(script); 305 // FIXME: Handle async 306 if (script->hasAttribute(deferAttr)) 307 requestDeferredScript(script); 308 else 309 requestParsingBlockingScript(script); 272 310 } else { 273 311 // FIXME: We do not block inline <script> tags on stylesheets to match the -
trunk/WebCore/html/HTMLScriptRunner.h
r63998 r64674 29 29 #include "CachedResourceClient.h" 30 30 #include "CachedResourceHandle.h" 31 #include <wtf/Deque.h> 31 32 #include <wtf/Noncopyable.h> 32 33 #include <wtf/PassRefPtr.h> … … 53 54 bool hasScriptsWaitingForStylesheets() const { return m_hasScriptsWaitingForStylesheets; } 54 55 bool executeScriptsWaitingForStylesheets(); 56 bool executeScriptsWaitingForParsing(); 55 57 56 58 bool isExecutingScript() { return !!m_scriptNestingLevel; } … … 64 66 // 65 67 // FIXME: Finish turning this into a proper class. 66 class PendingScript : public CachedResourceClient , Noncopyable{68 class PendingScript : public CachedResourceClient { 67 69 public: 68 70 PendingScript() … … 70 72 , m_watchingForLoad(false) 71 73 { 74 } 75 76 PendingScript(const PendingScript& other) 77 : CachedResourceClient(other) 78 , element(other.element) 79 , startingLineNumber(other.startingLineNumber) 80 , m_watchingForLoad(other.m_watchingForLoad) 81 { 82 setCachedScript(other.cachedScript()); 83 } 84 85 PendingScript& operator=(const PendingScript& other) 86 { 87 if (this == &other) 88 return *this; 89 90 element = other.element; 91 startingLineNumber = other.startingLineNumber; 92 m_watchingForLoad = other.m_watchingForLoad; 93 setCachedScript(other.cachedScript()); 94 95 return *this; 72 96 } 73 97 … … 102 126 void executePendingScript(); 103 127 104 void requestScript(Element*); 128 bool requestScript(PendingScript&, Element*); 129 void requestParsingBlockingScript(Element*); 130 void requestDeferredScript(Element*); 105 131 void runScript(Element*, int startingLineNumber); 106 132 … … 116 142 HTMLScriptRunnerHost* m_host; 117 143 PendingScript m_parsingBlockingScript; 144 Deque<PendingScript> m_scriptsToExecuteAfterParsing; 118 145 unsigned m_scriptNestingLevel; 119 146
Note: See TracChangeset
for help on using the changeset viewer.