Title: [288004] trunk
Revision
288004
Author
[email protected]
Date
2022-01-13 19:06:53 -0800 (Thu, 13 Jan 2022)

Log Message

html/semantics/scripting-1/the-script-element/script-type-and-language-empty.html WPT test is failing
https://bugs.webkit.org/show_bug.cgi?id=235202

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline test that is now passing.

* web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-empty-expected.txt:

Source/WebCore:

Per https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script (step 8), we should assume
the type is "text/_javascript_" if the type attribute is present and its value is the empty string.
Our logic in ScriptElement::determineScriptType() was slightly wrong and didn't get this case right
because it was doing an `isEmpty()` check which could mean both that the attribute is missing or present
with a value that is the empty string.

No new tests, rebaselined existing test.

* dom/ScriptElement.cpp:
(WebCore::ScriptElement::determineScriptType const):

Modified Paths

Diff

Modified: trunk/LayoutTests/fast/html/script-allowed-types-languages-expected.txt (288003 => 288004)


--- trunk/LayoutTests/fast/html/script-allowed-types-languages-expected.txt	2022-01-14 02:53:22 UTC (rev 288003)
+++ trunk/LayoutTests/fast/html/script-allowed-types-languages-expected.txt	2022-01-14 03:06:53 UTC (rev 288004)
@@ -41,9 +41,17 @@
 Type: "", Language: "_javascript_1.5"
 Type: "", Language: "_javascript_1.6"
 Type: "", Language: "_javascript_1.7"
+Type: "", Language: "_javascript_1.8"
+Type: "", Language: "_javascript_1.9"
 Type: "", Language: "ecmascript"
 Type: "", Language: "livescript"
 Type: "", Language: "jscript"
+Type: "", Language: "ebayScript"
+Type: "", Language: "    "
+Type: "", Language: "  _javascript_"
+Type: "", Language: "_javascript_  "
+Type: "", Language: "  _javascript_  "
+Type: "", Language: "abcdefg"
 When a type is specified, the language attribute should be ignored.
 Type: "text/_javascript_", Language: ""
 Type: "text/_javascript_", Language: "_javascript_"

Modified: trunk/LayoutTests/fast/tokenizer/004-expected.txt (288003 => 288004)


--- trunk/LayoutTests/fast/tokenizer/004-expected.txt	2022-01-14 02:53:22 UTC (rev 288003)
+++ trunk/LayoutTests/fast/tokenizer/004-expected.txt	2022-01-14 03:06:53 UTC (rev 288004)
@@ -168,5 +168,5 @@
 These scripts should not execute
 
 "_javascript_" language, "bogus" type
-empty string type, "bogus" language
+empty string type, "bogus" language executed
 empty string language, "bogus" type

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288003 => 288004)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-14 02:53:22 UTC (rev 288003)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-14 03:06:53 UTC (rev 288004)
@@ -1,5 +1,16 @@
 2022-01-13  Chris Dumez  <[email protected]>
 
+        html/semantics/scripting-1/the-script-element/script-type-and-language-empty.html WPT test is failing
+        https://bugs.webkit.org/show_bug.cgi?id=235202
+
+        Reviewed by Darin Adler.
+
+        Rebaseline test that is now passing.
+
+        * web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-empty-expected.txt:
+
+2022-01-13  Chris Dumez  <[email protected]>
+
         Implement HTMLScriptElement.supports(type) method
         https://bugs.webkit.org/show_bug.cgi?id=229929
         <rdar://problem/82933899>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-empty-expected.txt (288003 => 288004)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-empty-expected.txt	2022-01-14 02:53:22 UTC (rev 288003)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-empty-expected.txt	2022-01-14 03:06:53 UTC (rev 288004)
@@ -1,6 +1,6 @@
 
 PASS A script with empty type and no language should run
-FAIL A script with empty type and a random language should run assert_true: expected true got false
+PASS A script with empty type and a random language should run
 PASS A script with empty type and empty language should run
 PASS A script with no type and empty language should run
 

Modified: trunk/Source/WebCore/ChangeLog (288003 => 288004)


--- trunk/Source/WebCore/ChangeLog	2022-01-14 02:53:22 UTC (rev 288003)
+++ trunk/Source/WebCore/ChangeLog	2022-01-14 03:06:53 UTC (rev 288004)
@@ -1,3 +1,21 @@
+2022-01-13  Chris Dumez  <[email protected]>
+
+        html/semantics/scripting-1/the-script-element/script-type-and-language-empty.html WPT test is failing
+        https://bugs.webkit.org/show_bug.cgi?id=235202
+
+        Reviewed by Darin Adler.
+
+        Per https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script (step 8), we should assume
+        the type is "text/_javascript_" if the type attribute is present and its value is the empty string.
+        Our logic in ScriptElement::determineScriptType() was slightly wrong and didn't get this case right
+        because it was doing an `isEmpty()` check which could mean both that the attribute is missing or present
+        with a value that is the empty string.
+
+        No new tests, rebaselined existing test.
+
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::determineScriptType const):
+
 2022-01-13  Cameron McCormack  <[email protected]>
 
         Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements

Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (288003 => 288004)


--- trunk/Source/WebCore/dom/ScriptElement.cpp	2022-01-14 02:53:22 UTC (rev 288003)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp	2022-01-14 03:06:53 UTC (rev 288004)
@@ -135,6 +135,7 @@
     m_element.dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
+// https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script
 std::optional<ScriptElement::ScriptType> ScriptElement::determineScriptType(LegacyTypeSupport supportLegacyTypes) const
 {
     // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is used here to maintain backwards compatibility with existing layout tests. The specific violations are:
@@ -142,7 +143,7 @@
     // - Allowing a different set of languages for language= and type=. language= supports _javascript_ 1.1 and 1.4-1.6, but type= does not.
     String type = typeAttributeValue();
     String language = languageAttributeValue();
-    if (type.isEmpty()) {
+    if (type.isNull()) {
         if (language.isEmpty())
             return ScriptType::Classic; // Assume text/_javascript_.
         if (MIMETypeRegistry::isSupportedJavaScriptMIMEType("text/" + language))
@@ -151,6 +152,9 @@
             return ScriptType::Classic;
         return std::nullopt;
     }
+    if (type.isEmpty())
+        return ScriptType::Classic; // Assume text/_javascript_.
+
     if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()))
         return ScriptType::Classic;
     if (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to