Changeset 70282 in webkit
- Timestamp:
- Oct 21, 2010 6:27:27 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 deleted
- 12 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r70278 r70282 1 2010-10-21 Tony Gentilcore <tonyg@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Ignore document.write() when it comes from a network task 6 https://bugs.webkit.org/show_bug.cgi?id=47560 7 8 write()s from deferred scripts are now ignored. This matches the latest 9 Firefox 4 beta behavior. The defer-write expectations are updated, and 10 the other tests are now all moot since deferred scrits can't write(). 11 12 * fast/dom/HTMLScriptElement/defer-double-defer-write-expected.txt: Removed. 13 * fast/dom/HTMLScriptElement/defer-double-defer-write.html: Removed. 14 * fast/dom/HTMLScriptElement/defer-double-write-expected.txt: Removed. 15 * fast/dom/HTMLScriptElement/defer-double-write.html: Removed. 16 * fast/dom/HTMLScriptElement/defer-write.html: Updated to match FF4. 17 * fast/dom/HTMLScriptElement/remove-source-expected.txt: Added. 18 * fast/dom/HTMLScriptElement/remove-source.html: Added. Verifies that writes are still ignored when the src is removed after the script is requested but before it is executed. 19 * fast/dom/HTMLScriptElement/two-defer-writes-expected.txt: Removed. 20 * fast/dom/HTMLScriptElement/two-defer-writes.html: Removed. 21 * fast/dom/HTMLScriptElement/write-after-ignored-write-expected.txt: Added. Verifies that after a write from a network task is ignored, a write which is not from a network task still blows away the document. 22 * fast/dom/HTMLScriptElement/write-after-ignored-write.html: Added. 23 1 24 2010-10-21 James Robinson <jamesr@chromium.org> 2 25 -
trunk/LayoutTests/fast/dom/HTMLScriptElement/defer-write.html
r66670 r70282 3 3 layoutTestController.dumpAsText(); 4 4 </script> 5 FAIL 6 <script defer src="data:text/javascript,document.write(' PASS');"></script>5 PASS 6 <script defer src="data:text/javascript,document.write('FAIL');"></script> -
trunk/LayoutTests/fast/dom/HTMLScriptElement/remove-source-expected.txt
- Property svn:executable deleted
-
trunk/LayoutTests/fast/dom/HTMLScriptElement/write-after-ignored-write.html
r70281 r70282 3 3 layoutTestController.dumpAsText(); 4 4 </script> 5 <body onload="document.write('PASS')"> 5 6 FAIL 6 <script defer src="data:text/javascript,document.write('PASS');"></script>7 7 <script defer src="data:text/javascript,document.write('FAIL');"></script> 8 -
trunk/WebCore/ChangeLog
r70281 r70282 1 2010-10-21 Tony Gentilcore <tonyg@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Ignore document.write() when it comes from a network task 6 https://bugs.webkit.org/show_bug.cgi?id=47560 7 8 This implements the update to the spec made by: 9 http://www.w3.org/Bugs/Public/show_bug.cgi?id=9767 10 11 It also matches the latest Firefox 4 beta. The notable change is that 12 document.write from a deferred script no longer works. This avoids 13 blowing the patch away. 14 15 * dom/Document.cpp: 16 (WebCore::Document::Document): 17 (WebCore::Document::write): 18 * dom/Document.h: 19 (WebCore::DestructiveWriteCountIncrementer::DestructiveWriteCountIncrementer): 20 (WebCore::Document::ignoreDestructiveWriteCountIncrementer): 21 * dom/ScriptElement.cpp: 22 (WebCore::ScriptElement::insertedIntoDocument): 23 (WebCore::ScriptElementData::ScriptElementData): 24 (WebCore::ScriptElementData::evaluateScript): 25 * dom/ScriptElement.h: 26 * html/parser/HTMLScriptRunner.cpp: 27 (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): 28 1 29 2010-10-21 Ryosuke Niwa <rniwa@webkit.org> 2 30 -
trunk/WebCore/GNUmakefile.am
r70235 r70282 1142 1142 WebCore/dom/ExceptionCode.h \ 1143 1143 WebCore/dom/FragmentScriptingPermission.h \ 1144 WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h \ 1144 1145 WebCore/dom/InputElement.cpp \ 1145 1146 WebCore/dom/InputElement.h \ -
trunk/WebCore/WebCore.gypi
r70240 r70282 1213 1213 'dom/ExceptionCode.h', 1214 1214 'dom/FragmentScriptingPermission.h', 1215 'dom/IgnoreDestructiveWriteCountIncrementer.h', 1215 1216 'dom/InputElement.cpp', 1216 1217 'dom/InputElement.h', -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r70235 r70282 42204 42204 </File> 42205 42205 <File 42206 RelativePath="..\dom\IgnoreDestructiveWriteCountIncrementer.h" 42207 > 42208 </File> 42209 <File 42206 42210 RelativePath="..\dom\InputElement.h" 42207 42211 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r70263 r70282 2598 2598 8A9A588711E84F37008ACFD1 /* JSTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A9A587611E84C98008ACFD1 /* JSTiming.cpp */; }; 2599 2599 8A9A588811E84F37008ACFD1 /* JSTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A9A587711E84C98008ACFD1 /* JSTiming.h */; }; 2600 8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AB4BC76126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h */; }; 2600 2601 8AF4E55511DC5A36000ED3DE /* Navigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AF4E55211DC5A36000ED3DE /* Navigation.cpp */; }; 2601 2602 8AF4E55611DC5A36000ED3DE /* Navigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AF4E55311DC5A36000ED3DE /* Navigation.h */; }; … … 8661 8662 8A9A587611E84C98008ACFD1 /* JSTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTiming.cpp; sourceTree = "<group>"; }; 8662 8663 8A9A587711E84C98008ACFD1 /* JSTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTiming.h; sourceTree = "<group>"; }; 8664 8AB4BC76126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IgnoreDestructiveWriteCountIncrementer.h; sourceTree = "<group>"; }; 8663 8665 8AF4E55211DC5A36000ED3DE /* Navigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Navigation.cpp; sourceTree = "<group>"; }; 8664 8666 8AF4E55311DC5A36000ED3DE /* Navigation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Navigation.h; sourceTree = "<group>"; }; … … 18099 18101 2442BBF81194C9D300D49469 /* HashChangeEvent.h */, 18100 18102 8482B7441198C32E00BFB005 /* HashChangeEvent.idl */, 18103 8AB4BC76126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h */, 18101 18104 08700BE60F086C5300919419 /* InputElement.cpp */, 18102 18105 08591AA40F085C4E009BACB1 /* InputElement.h */, … … 21142 21145 089021A9126EF5DE0092D5EA /* SVGAnimatedLength.h in Headers */, 21143 21146 089021AD126EF5E90092D5EA /* SVGAnimatedLengthList.h in Headers */, 21147 8AB4BC77126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h in Headers */, 21144 21148 ); 21145 21149 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/dom/Document.cpp
r70047 r70282 365 365 , m_containsValidityStyleRules(false) 366 366 , m_updateFocusAppearanceRestoresSelection(false) 367 , m_ writeDisabled(false)367 , m_ignoreDestructiveWriteCount(0) 368 368 , m_title("") 369 369 , m_rawTitle("") … … 2130 2130 #endif 2131 2131 2132 // If the insertion point is undefined and the Document has the2133 // "write-neutralised" flag set, then abort these steps.2134 2132 bool hasInsertionPoint = m_parser && m_parser->hasInsertionPoint(); 2135 if (!hasInsertionPoint && writeDisabled())2133 if (!hasInsertionPoint && m_ignoreDestructiveWriteCount) 2136 2134 return; 2137 2135 -
trunk/WebCore/dom/Document.h
r70047 r70282 1031 1031 #endif 1032 1032 1033 bool writeDisabled() const { return m_writeDisabled; }1034 void setWriteDisabled(bool flag) { m_writeDisabled = flag; }1035 1036 1033 // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event. 1037 1034 void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; } … … 1050 1047 1051 1048 private: 1049 friend class IgnoreDestructiveWriteCountIncrementer; 1050 1052 1051 void detachParser(); 1053 1052 … … 1204 1203 bool m_updateFocusAppearanceRestoresSelection; 1205 1204 1206 // http://www.whatwg.org/specs/web-apps/current-work/# write-neutralised1207 bool m_writeDisabled;1205 // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter 1206 unsigned m_ignoreDestructiveWriteCount; 1208 1207 1209 1208 String m_title; -
trunk/WebCore/dom/ScriptElement.cpp
r67245 r70282 34 34 #include "HTMLNames.h" 35 35 #include "HTMLScriptElement.h" 36 #include "IgnoreDestructiveWriteCountIncrementer.h" 36 37 #include "MIMETypeRegistry.h" 37 38 #include "Page.h" … … 57 58 58 59 // http://www.whatwg.org/specs/web-apps/current-work/#script 59 60 // If the element's Document has an active parser, and the parser's script61 // nesting level is non-zero, but this script element does not have the62 // "parser-inserted" flag set, the user agent must set the element's63 // "write-neutralised" flag.64 DocumentParser* parser = data.element()->document()->parser();65 if (parser && parser->hasInsertionPoint())66 data.setWriteDisabled(true);67 60 68 61 if (!sourceUrl.isEmpty()) { … … 143 136 , m_cachedScript(0) 144 137 , m_createdByParser(false) 145 , m_writeDisabled(false)146 138 , m_requested(false) 147 139 , m_evaluated(false) … … 192 184 return; 193 185 194 if (Frame* frame = m_element->document()->frame()) { 186 RefPtr<Document> document = m_element->document(); 187 ASSERT(document); 188 if (Frame* frame = document->frame()) { 195 189 if (!frame->script()->canExecuteScripts(AboutToExecuteScript)) 196 190 return; … … 200 194 // http://www.whatwg.org/specs/web-apps/current-work/#script 201 195 202 // If the script element's "write-neutralised" flag is set, then flag 203 // the Document the script element was in when the "write-neutralised" 204 // flag was set as being itself "write-neutralised". Let neutralised doc 205 // be that Document. 206 if (m_writeDisabled) { 207 ASSERT(!m_element->document()->writeDisabled()); 208 m_element->document()->setWriteDisabled(true); 209 } 210 211 // Create a script from the script element node, using the script 212 // block's source and the script block's type. 213 // Note: This is where the script is compiled and actually executed. 214 frame->script()->evaluate(sourceCode); 215 216 // Remove the "write-neutralised" flag from neutralised doc, if it was 217 // set in the earlier step. 218 if (m_writeDisabled) { 219 ASSERT(m_element->document()->writeDisabled()); 220 m_element->document()->setWriteDisabled(false); 196 { 197 IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_requested ? document.get() : 0); 198 // Create a script from the script element node, using the script 199 // block's source and the script block's type. 200 // Note: This is where the script is compiled and actually executed. 201 frame->script()->evaluate(sourceCode); 221 202 } 222 203 -
trunk/WebCore/dom/ScriptElement.h
r63998 r70282 83 83 bool createdByParser() const { return m_createdByParser; } 84 84 void setCreatedByParser(bool value) { m_createdByParser = value; } 85 bool writeDisabled() const { return m_writeDisabled; }86 void setWriteDisabled(bool value) { m_writeDisabled = value; }87 85 bool haveFiredLoadEvent() const { return m_firedLoad; } 88 86 void setHaveFiredLoadEvent(bool firedLoad) { m_firedLoad = firedLoad; } … … 102 100 CachedResourceHandle<CachedScript> m_cachedScript; 103 101 bool m_createdByParser; // HTML5: "parser-inserted" 104 bool m_writeDisabled; // http://www.whatwg.org/specs/web-apps/current-work/#write-neutralised105 102 bool m_requested; 106 103 bool m_evaluated; // HTML5: "already started" -
trunk/WebCore/html/parser/HTMLScriptRunner.cpp
r70181 r70282 36 36 #include "HTMLInputStream.h" 37 37 #include "HTMLNames.h" 38 #include "IgnoreDestructiveWriteCountIncrementer.h" 38 39 #include "NestingLevelIncrementer.h" 39 40 #include "NotImplemented.h" … … 136 137 { 137 138 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); 139 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(m_document); 138 140 if (errorOccurred) 139 141 scriptElement->dispatchEvent(createScriptErrorEvent());
Note: See TracChangeset
for help on using the changeset viewer.