[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
tonyg at chromium.org
tonyg at chromium.org
Wed Dec 22 13:18:53 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit bd35ae25d716a31df6f56aeacd0e1d5bbd1ffe79
Author: tonyg at chromium.org <tonyg at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Sep 10 22:38:40 2010 +0000
2010-09-10 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Eric Seidel.
Implement HTML5 definition of script for-event neutering
https://bugs.webkit.org/show_bug.cgi?id=45493
* fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt:
* fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js: Beef up test with some more cases, change style to be more readable, and remove obsolete comments about supporting for-event.
2010-09-10 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Eric Seidel.
Implement HTML5 definition of script for-event neutering
https://bugs.webkit.org/show_bug.cgi?id=45493
* dom/ScriptElement.cpp:
(WebCore::ScriptElementData::shouldExecuteAsJavaScript): Same behavior, but reads more like the spec. Removed obsolete comments about supporting for-event.
* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::executeScript): Moved to runScript.
(WebCore::HTMLScriptRunner::runScript): Checking shouldExecuteAsJavaScript() here means that external scripts which fail the check will never be requested.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3df2609..30de44f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-10 Tony Gentilcore <tonyg at chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Implement HTML5 definition of script for-event neutering
+ https://bugs.webkit.org/show_bug.cgi?id=45493
+
+ * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt:
+ * fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js: Beef up test with some more cases, change style to be more readable, and remove obsolete comments about supporting for-event.
+
2010-09-10 Ryosuke Niwa <rniwa at webkit.org>
Reviewed by Eric Seidel.
diff --git a/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt b/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt
index 65111de..5081faa 100644
--- a/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt
+++ b/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt
@@ -1,13 +1,15 @@
-If a script has a for attribute, then it was intended to only be run under certain conditions, often as a result of a certain window event.
-Since we don't yet support the full for attribute syntax we would run these scripts as we parsed them, often causing unintentional breakage of the site in question.
-You should *not* see any failure when running this test. If you do, we're not properly running these scripts only when they were intended to be run.
+Tests that scripts which have a for-event other than window.onload are not executed.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS scriptForExecuted is false
-PASS scriptForExecuted is false
-PASS scriptForExecuted is false
+PASS for=window
+PASS for=anything
+PASS event=onload
+PASS event=anything
+PASS for=window event=onload
+PASS for=window event=onload()
+PASS for=WINDOW event=ONLOAD()
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/LayoutTests/fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js b/LayoutTests/fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js
index d849dbf..bab7356 100644
--- a/LayoutTests/fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js
+++ b/LayoutTests/fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js
@@ -1,17 +1,14 @@
-description("If a script has a for attribute, then it was intended to only be run under certain conditions, often as a result of a certain window event.<br>Since we don't yet support the full for attribute syntax we would run these scripts as we parsed them, often causing unintentional breakage of the site in question.<br>You should *not* see any failure when running this test. If you do, we're not properly running these scripts only when they were intended to be run.");
-
-// A variable indicates the script-for attribute doesn't get executed immediately.
-var scriptForExecuted = false;
-
-function ScriptForAttributeExecute() {
- scriptForExecuted = true;
-}
-
-document.write('<script for=window event=onresize> ScriptForAttributeExecute(); </script>');
-shouldBe('scriptForExecuted', "false");
-document.write('<script for=window event=onresize type="text/javascript"> ScriptForAttributeExecute(); </script>');
-shouldBe('scriptForExecuted', "false");
-document.write('<script for=window event=onresize language="javascript"> ScriptForAttributeExecute(); </script>');
-shouldBe('scriptForExecuted', "false");
+description("Tests that scripts which have a for-event other than window.onload are not executed.");
+
+document.write('<script for="window">testPassed(\'for=window\');</script>');
+document.write('<script for="anything">testPassed(\'for=anything\');</script>');
+document.write('<script event="onload">testPassed(\'event=onload\');</script>');
+document.write('<script event="anything">testPassed(\'event=anything\');</script>');
+document.write('<script for="window" event="onload">testPassed(\'for=window event=onload\');</script>');
+document.write('<script for="window" event="onload()">testPassed(\'for=window event=onload()\');</script>');
+document.write('<script for=" WINDOW " event=" ONLOAD() ">testPassed(\'for=WINDOW event=ONLOAD()\');</script>');
+document.write('<script for="window" event="onresize">testFailed(\'for=window event=onresize\');</script>');
+document.write('<script for="document" event="onload">testFailed(\'for=document event=onload\');</script>');
+document.write('<script for="document" event="onclick">testFailed(\'for=document event=onclick\');</script>');
var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fb411e9..2e83c9a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2010-09-10 Tony Gentilcore <tonyg at chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ Implement HTML5 definition of script for-event neutering
+ https://bugs.webkit.org/show_bug.cgi?id=45493
+
+ * dom/ScriptElement.cpp:
+ (WebCore::ScriptElementData::shouldExecuteAsJavaScript): Same behavior, but reads more like the spec. Removed obsolete comments about supporting for-event.
+ * html/parser/HTMLScriptRunner.cpp:
+ (WebCore::HTMLScriptRunner::executeScript): Moved to runScript.
+ (WebCore::HTMLScriptRunner::runScript): Checking shouldExecuteAsJavaScript() here means that external scripts which fail the check will never be requested.
+
2010-09-10 Nat Duca <nduca at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp
index bb46f0a..46c85e3 100644
--- a/WebCore/dom/ScriptElement.cpp
+++ b/WebCore/dom/ScriptElement.cpp
@@ -264,6 +264,8 @@ bool ScriptElementData::shouldExecuteAsJavaScript() const
WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't.
Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace.
We want to accept all the values that either of these browsers accept, but not other values.
+
+ FIXME: Is this HTML5 compliant?
*/
String type = m_scriptElement->typeAttributeValue();
if (!type.isEmpty()) {
@@ -276,20 +278,20 @@ bool ScriptElementData::shouldExecuteAsJavaScript() const
}
// No type or language is specified, so we assume the script to be JavaScript.
- // We don't yet support setting event listeners via the 'for' attribute for scripts.
- // If there is such an attribute it's likely better to not execute the script than to do so
- // immediately and unconditionally.
- // FIXME: After <rdar://problem/4471751> / https://bugs.webkit.org/show_bug.cgi?id=16915 are resolved
- // and we support the for syntax in script tags, this check can be removed and we should just
- // return 'true' here.
+
String forAttribute = m_scriptElement->forAttributeValue();
String eventAttribute = m_scriptElement->eventAttributeValue();
- if (forAttribute.isEmpty() || eventAttribute.isEmpty())
- return true;
+ if (!forAttribute.isEmpty() && !eventAttribute.isEmpty()) {
+ forAttribute = forAttribute.stripWhiteSpace();
+ if (!equalIgnoringCase(forAttribute, "window"))
+ return false;
+
+ eventAttribute = eventAttribute.stripWhiteSpace();
+ if (!equalIgnoringCase(eventAttribute, "onload") && !equalIgnoringCase(eventAttribute, "onload()"))
+ return false;
+ }
- forAttribute = forAttribute.stripWhiteSpace();
- eventAttribute = eventAttribute.stripWhiteSpace();
- return equalIgnoringCase(forAttribute, "window") && (equalIgnoringCase(eventAttribute, "onload") || equalIgnoringCase(eventAttribute, "onload()"));
+ return true;
}
String ScriptElementData::scriptCharset() const
diff --git a/WebCore/html/parser/HTMLScriptRunner.cpp b/WebCore/html/parser/HTMLScriptRunner.cpp
index 4953bd3..4f54f42 100644
--- a/WebCore/html/parser/HTMLScriptRunner.cpp
+++ b/WebCore/html/parser/HTMLScriptRunner.cpp
@@ -138,20 +138,16 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
if (errorOccurred)
scriptElement->dispatchEvent(createScriptErrorEvent());
else {
- executeScript(scriptElement.get(), sourceCode);
+ executeScript(sourceCode);
scriptElement->dispatchEvent(createScriptLoadEvent());
}
}
ASSERT(!m_scriptNestingLevel);
}
-void HTMLScriptRunner::executeScript(Element* element, const ScriptSourceCode& sourceCode) const
+void HTMLScriptRunner::executeScript(const ScriptSourceCode& sourceCode) const
{
ASSERT(m_document);
- ScriptElement* scriptElement = toScriptElement(element);
- ASSERT(scriptElement);
- if (!scriptElement->shouldExecuteAsJavaScript())
- return;
ASSERT(isExecutingScript());
if (!m_document->frame())
return;
@@ -300,9 +296,11 @@ void HTMLScriptRunner::runScript(Element* script, int startingLineNumber)
InsertionPointRecord insertionPointRecord(m_host->inputStream());
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
- // Check script type and language, current code uses ScriptElement::shouldExecuteAsJavaScript(), but that may not be HTML5 compliant.
- notImplemented(); // event for support
-
+ ScriptElement* scriptElement = toScriptElement(script);
+ ASSERT(scriptElement);
+ if (!scriptElement->shouldExecuteAsJavaScript())
+ return;
+
if (script->hasAttribute(srcAttr)) {
if (script->hasAttribute(asyncAttr)) // Async takes precendence over defer.
return; // Asynchronous scripts handle themselves.
@@ -318,7 +316,7 @@ void HTMLScriptRunner::runScript(Element* script, int startingLineNumber)
// ASSERT(document()->haveStylesheetsLoaded());
ASSERT(isExecutingScript());
ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), startingLineNumber);
- executeScript(script, sourceCode);
+ executeScript(sourceCode);
}
}
}
diff --git a/WebCore/html/parser/HTMLScriptRunner.h b/WebCore/html/parser/HTMLScriptRunner.h
index 47c96fd..be21dd2 100644
--- a/WebCore/html/parser/HTMLScriptRunner.h
+++ b/WebCore/html/parser/HTMLScriptRunner.h
@@ -68,7 +68,7 @@ private:
void executeParsingBlockingScript();
void executePendingScriptAndDispatchEvent(PendingScript&);
- void executeScript(Element*, const ScriptSourceCode&) const;
+ void executeScript(const ScriptSourceCode&) const;
bool haveParsingBlockingScript() const;
bool executeParsingBlockingScripts();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list