Changeset 51097 in webkit


Ignore:
Timestamp:
Nov 17, 2009 4:35:56 PM (14 years ago)
Author:
dimich@chromium.org
Message:

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@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@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):

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r51096 r51097  
     12009-11-17  Johnny Ding  <jnd@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        In all valid script tags for JavaScript, the event handler in <script...for> should not get executed.
     6        Change the original test to pure js test, and test the situation about script tags which have text or language attribute.
     7        https://bugs.webkit.org/show_bug.cgi?id=31567
     8
     9        * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt:
     10        * fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html:
     11        * fast/dom/HTMLScriptElement/script-tests: Added.
     12        * fast/dom/HTMLScriptElement/script-tests/script-for-attribute-unexpected-execution.js: Added.
     13        (ScriptForAttributeExecute):
     14
    1152009-11-17  Mark Rowe  <mrowe@apple.com>
    216
  • trunk/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution-expected.txt

    r43061 r51097  
    11If 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.
    22Since 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.
    3 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.
     3You 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.
     4
     5On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     6
     7
     8PASS scriptForExecuted is false
     9PASS scriptForExecuted is false
     10PASS scriptForExecuted is false
     11PASS successfullyParsed is true
     12
     13TEST COMPLETE
     14
  • trunk/LayoutTests/fast/dom/HTMLScriptElement/script-for-attribute-unexpected-execution.html

    r43061 r51097  
     1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    12<html>
    23<head>
    3 <script>
    4 if (window.layoutTestController)
    5     layoutTestController.dumpAsText();
    6 </script>
    7 
    8 <script for=window event=onresize>
    9 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");
    10 </script>
    11 
     4<link rel="stylesheet" href="../../js/resources/js-test-style.css">
     5<script src="../../js/resources/js-test-pre.js"></script>
    126</head>
    137<body>
    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.<br>
    15 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>
    16 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.
     8<p id="description"></p>
     9<div id="console"></div>
     10<script src="script-tests/script-for-attribute-unexpected-execution.js"></script>
     11<script src="../../js/resources/js-test-post.js"></script>
    1712</body>
    1813</html>
     14
  • trunk/WebCore/ChangeLog

    r51072 r51097  
     12009-11-17  Johnny Ding  <jnd@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        In all valid script tags for JavaScript, the event handler in <script...for> should not get executed.
     6        https://bugs.webkit.org/show_bug.cgi?id=31567
     7
     8        * dom/ScriptElement.cpp:
     9        (WebCore::ScriptElementData::shouldExecuteAsJavaScript):
     10
    1112009-11-17  Pavel Feldman  <pfeldman@chromium.org>
    212
  • trunk/WebCore/dom/ScriptElement.cpp

    r49208 r51097  
    230230     */
    231231    String type = m_scriptElement->typeAttributeValue();
    232     if (!type.isEmpty())
    233         return MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower());
    234 
    235     String language = m_scriptElement->languageAttributeValue();
    236     if (!language.isEmpty())
    237         return isSupportedJavaScriptLanguage(language);
     232    if (!type.isEmpty()) {
     233        if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower()))
     234            return false;
     235    } else {
     236        String language = m_scriptElement->languageAttributeValue();
     237        if (!language.isEmpty() && !isSupportedJavaScriptLanguage(language))
     238            return false;
     239    }   
    238240
    239241    // No type or language is specified, so we assume the script to be JavaScript.
Note: See TracChangeset for help on using the changeset viewer.