[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

dimich at chromium.org dimich at chromium.org
Wed Apr 7 23:46:00 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 3be377c34f649af85b37c91c84976661ac20bfc1
Author: dimich at chromium.org <dimich at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 18 00:35:56 2009 +0000

    WebCore: In all valid script tags for JavaScript, the event handler in <script...for> should not get executed.
    https://bugs.webkit.org/show_bug.cgi?id=31567
    
    Patch by Johnny Ding <jnd at chromium.org> on 2009-11-17
    Reviewed by Darin Adler.
    
    * dom/ScriptElement.cpp:
    (WebCore::ScriptElementData::shouldExecuteAsJavaScript):
    
    LayoutTests: In all valid script tags for JavaScript, the event handler in <script...for> should not get executed.
    Change the original test to pure js test, and test the situation about script tags which have text or language attribute.
    https://bugs.webkit.org/show_bug.cgi?id=31567
    
    Patch by Johnny Ding <jnd at chromium.org> on 2009-11-17
    Reviewed by Darin Adler.
    
    * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt:
    * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html:
    * fast/dom/HTMLScriptElement/script-tests: Added.
    * fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js: Added.
    (ScriptForAttributeExecute):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51097 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3538993..5f1e0f9 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2009-11-17  Johnny Ding  <jnd at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        In all valid script tags for JavaScript, the event handler in <script...for> should not get executed.
+        Change the original test to pure js test, and test the situation about script tags which have text or language attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=31567
+
+        * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt:
+        * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html:
+        * fast/dom/HTMLScriptElement/script-tests: Added.
+        * fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js: Added.
+        (ScriptForAttributeExecute):
+
 2009-11-17  Mark Rowe  <mrowe at apple.com>
 
         Reviewed by Alexey Proskuryakov.
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 a1d0854..65111de 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,3 +1,14 @@
 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 the alert() that is in a script element on this page. If you do, we're not properly running these scripts only when they were intended to be run.
+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.
+
+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 successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html b/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html
index 83a1882..cf1f924 100644
--- a/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html
+++ b/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html
@@ -1,18 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
-<script>
-if (window.layoutTestController)
-    layoutTestController.dumpAsText();
-</script>
-
-<script for=window event=onresize>
-alert("This text should only be alerted if the window is resizing.  If you see it as a mere result of the page loading, then you're seeing a symptom that breaks real world websites");
-</script>
-
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
 </head>
 <body>
-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 the alert() that is in a script element on this page.  If you do, we're not properly running these scripts only when they were intended to be run.
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/script-for-attribute-unexpected-execution.js"></script>
+<script src="../../js/resources/js-test-post.js"></script>
 </body>
 </html>
+
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
new file mode 100644
index 0000000..d849dbf
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js
@@ -0,0 +1,17 @@
+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");
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 565ee61..0ccb730 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2009-11-17  Johnny Ding  <jnd at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        In all valid script tags for JavaScript, the event handler in <script...for> should not get executed.
+        https://bugs.webkit.org/show_bug.cgi?id=31567
+
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElementData::shouldExecuteAsJavaScript):
+
 2009-11-17  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp
index 827aff3..83ed2bb 100644
--- a/WebCore/dom/ScriptElement.cpp
+++ b/WebCore/dom/ScriptElement.cpp
@@ -229,12 +229,14 @@ bool ScriptElementData::shouldExecuteAsJavaScript() const
          We want to accept all the values that either of these browsers accept, but not other values.
      */
     String type = m_scriptElement->typeAttributeValue();
-    if (!type.isEmpty())
-        return MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower());
-
-    String language = m_scriptElement->languageAttributeValue();
-    if (!language.isEmpty())
-        return isSupportedJavaScriptLanguage(language);
+    if (!type.isEmpty()) {
+        if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower()))
+            return false;
+    } else {
+        String language = m_scriptElement->languageAttributeValue();
+        if (!language.isEmpty() && !isSupportedJavaScriptLanguage(language))
+            return false;
+    }    
 
     // 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.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list