Diff
Modified: trunk/LayoutTests/ChangeLog (203739 => 203740)
--- trunk/LayoutTests/ChangeLog 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/ChangeLog 2016-07-26 22:00:20 UTC (rev 203740)
@@ -1,3 +1,21 @@
+2016-07-26 Chris Dumez <[email protected]>
+
+ Parameters to CSSStyleSheet.insertRule() / deleteRule() should be mandatory
+ https://bugs.webkit.org/show_bug.cgi?id=160210
+
+ Reviewed by Darin Adler.
+
+ * fast/css/stylesheet-parameters-expected.txt: Added.
+ * fast/css/stylesheet-parameters.html: Added.
+ Add layout test coverage.
+
+ * editing/selection/first-letter-selection-crash.html:
+ * fast/css/counters/asterisk-counter-update-after-layout-crash.html:
+ * fast/dom/HTMLElement/dynamic-editability-change.html:
+ * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
+ * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
+ Update existing tests to reflect the behavior change.
+
2016-07-26 George Ruan <[email protected]>
HTMLVideoElement frames do not update on iOS when src is a MediaStream blob
Modified: trunk/LayoutTests/editing/selection/first-letter-selection-crash.html (203739 => 203740)
--- trunk/LayoutTests/editing/selection/first-letter-selection-crash.html 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/editing/selection/first-letter-selection-crash.html 2016-07-26 22:00:20 UTC (rev 203740)
@@ -19,7 +19,7 @@
test1.appendChild(document.createTextNode('a'));
document.execCommand('selectall');
document.body.offsetTop;
- document.styleSheets[0].insertRule("#test2 { text-transform: uppercase }");
+ document.styleSheets[0].insertRule("#test2 { text-transform: uppercase }", 0);
document.body.offsetTop;
document.body.innerHTML = "PASS";
}
Modified: trunk/LayoutTests/fast/css/counters/asterisk-counter-update-after-layout-crash.html (203739 => 203740)
--- trunk/LayoutTests/fast/css/counters/asterisk-counter-update-after-layout-crash.html 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/fast/css/counters/asterisk-counter-update-after-layout-crash.html 2016-07-26 22:00:20 UTC (rev 203740)
@@ -3,7 +3,7 @@
</style>
<script>
function runTest() {
- document.styleSheets[0].insertRule("div { counter-reset: c 141170 }");
+ document.styleSheets[0].insertRule("div { counter-reset: c 141170 }", 0);
if (window.testRunner)
testRunner.dumpAsText();
}
Added: trunk/LayoutTests/fast/css/stylesheet-parameters-expected.txt (0 => 203740)
--- trunk/LayoutTests/fast/css/stylesheet-parameters-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/stylesheet-parameters-expected.txt 2016-07-26 22:00:20 UTC (rev 203740)
@@ -0,0 +1,14 @@
+CONSOLE MESSAGE: line 1: Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).
+Tests that the parameters to CSSStyleSheet.insertRule() / deleteRule() are mandatory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS stylesheet.__proto__ is CSSStyleSheet.prototype
+PASS stylesheet.deleteRule() threw exception TypeError: Not enough arguments.
+PASS stylesheet.insertRule() threw exception TypeError: Not enough arguments.
+FAIL stylesheet.insertRule('body { margin: 0; }') should throw TypeError: Not enough arguments. Was 0.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css/stylesheet-parameters.html (0 => 203740)
--- trunk/LayoutTests/fast/css/stylesheet-parameters.html (rev 0)
+++ trunk/LayoutTests/fast/css/stylesheet-parameters.html 2016-07-26 22:00:20 UTC (rev 203740)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that the parameters to CSSStyleSheet.insertRule() / deleteRule() are mandatory.");
+
+var styleElement = document.createElement("style");
+document.head.appendChild(styleElement);
+var stylesheet = styleElement.sheet;
+shouldBe("stylesheet.__proto__", "CSSStyleSheet.prototype");
+shouldThrow("stylesheet.deleteRule()", "'TypeError: Not enough arguments'");
+shouldThrow("stylesheet.insertRule()", "'TypeError: Not enough arguments'");
+shouldThrow("stylesheet.insertRule('body { margin: 0; }')", "'TypeError: Not enough arguments'");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/dom/HTMLElement/dynamic-editability-change-expected.txt (203739 => 203740)
--- trunk/LayoutTests/fast/dom/HTMLElement/dynamic-editability-change-expected.txt 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/fast/dom/HTMLElement/dynamic-editability-change-expected.txt 2016-07-26 22:00:20 UTC (rev 203740)
@@ -17,8 +17,8 @@
PASS newDoc("<div></div>"); style = element("style", "* { -webkit-user-modify: read-write }"); $("div").isContentEditable is false
PASS $("body").appendChild(style); $("div").isContentEditable is true
PASS newDoc("<div></div><style></style>"); $("div").isContentEditable is false
-PASS $("style").sheet.insertRule("* { -webkit-user-modify: read-write; }"); $("div").isContentEditable is true
-PASS $("style").sheet.insertRule("* { -webkit-user-modify: read-only !important; }"); $("div").isContentEditable is false
+PASS $("style").sheet.insertRule("* { -webkit-user-modify: read-write; }", 0); $("div").isContentEditable is true
+PASS $("style").sheet.insertRule("* { -webkit-user-modify: read-only !important; }", 0); $("div").isContentEditable is false
Inline styles
PASS newDoc("<div style='-webkit-user-modify:read-write'></div>"); $("div").isContentEditable is true
Modified: trunk/LayoutTests/fast/dom/HTMLElement/dynamic-editability-change.html (203739 => 203740)
--- trunk/LayoutTests/fast/dom/HTMLElement/dynamic-editability-change.html 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/fast/dom/HTMLElement/dynamic-editability-change.html 2016-07-26 22:00:20 UTC (rev 203740)
@@ -36,8 +36,8 @@
shouldBeFalse('newDoc("<div></div>"); style = element("style", "* { -webkit-user-modify: read-write }"); $("div").isContentEditable');
shouldBeTrue('$("body").appendChild(style); $("div").isContentEditable');
shouldBeFalse('newDoc("<div></div><style></style>"); $("div").isContentEditable');
-shouldBeTrue('$("style").sheet.insertRule("* { -webkit-user-modify: read-write; }"); $("div").isContentEditable');
-shouldBeFalse('$("style").sheet.insertRule("* { -webkit-user-modify: read-only !important; }"); $("div").isContentEditable');
+shouldBeTrue('$("style").sheet.insertRule("* { -webkit-user-modify: read-write; }", 0); $("div").isContentEditable');
+shouldBeFalse('$("style").sheet.insertRule("* { -webkit-user-modify: read-only !important; }", 0); $("div").isContentEditable');
debug('');
debug('Inline styles');
Modified: trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt (203739 => 203740)
--- trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt 2016-07-26 22:00:20 UTC (rev 203740)
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: line 1: Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).
This tests the behavior of non-numeric values in contexts where the DOM has a numeric parameter.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -15,7 +16,7 @@
PASS nonNumericPolicy('createCSSRuleList().item(x)') is 'any type allowed'
PASS nonNumericPolicy('createCSSStyleDeclaration().item(x)') is 'any type allowed'
PASS nonNumericPolicy('createCSSStyleSheet().insertRule(ruleText, x)') is 'any type allowed'
-PASS nonNumericPolicy('createCSSStyleSheet().deleteRule(x)') is 'any type allowed'
+PASS nonNumericPolicy('createCSSStyleSheet().deleteRule(x)') is 'any type allowed (but not omitted)'
PASS nonNumericPolicy('createCSSStyleSheet().addRule(selector, styleText, x)') is 'any type allowed'
PASS nonNumericPolicy('createCSSStyleSheet().removeRule(x)') is 'any type allowed'
PASS nonNumericPolicy('createCSSValueList().item(x)') is 'any type allowed'
Modified: trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js (203739 => 203740)
--- trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js 2016-07-26 22:00:20 UTC (rev 203740)
@@ -209,7 +209,7 @@
// CSSStyleSheet
shouldBe("nonNumericPolicy('createCSSStyleSheet().insertRule(ruleText, x)')", "'any type allowed'");
-shouldBe("nonNumericPolicy('createCSSStyleSheet().deleteRule(x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('createCSSStyleSheet().deleteRule(x)')", "'any type allowed (but not omitted)'");
shouldBe("nonNumericPolicy('createCSSStyleSheet().addRule(selector, styleText, x)')", "'any type allowed'");
shouldBe("nonNumericPolicy('createCSSStyleSheet().removeRule(x)')", "'any type allowed'");
Modified: trunk/Source/WebCore/ChangeLog (203739 => 203740)
--- trunk/Source/WebCore/ChangeLog 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/Source/WebCore/ChangeLog 2016-07-26 22:00:20 UTC (rev 203740)
@@ -1,3 +1,27 @@
+2016-07-26 Chris Dumez <[email protected]>
+
+ Parameters to CSSStyleSheet.insertRule() / deleteRule() should be mandatory
+ https://bugs.webkit.org/show_bug.cgi?id=160210
+
+ Reviewed by Darin Adler.
+
+ Parameters to CSSStyleSheet.insertRule() / deleteRule() should be mandatory:
+ - https://drafts.csswg.org/cssom/#cssstylesheet
+
+ They are mandatory in Firefox.
+ They are mandatory in Chrome except for the second parameter of insertRule()
+ which merely logs a deprecation warning.
+
+ This patch aligns our behavior with Chrome to move towards to specification
+ while limiting the risk of breakage.
+
+ Test: fast/css/stylesheet-parameters.html
+
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::deprecatedInsertRule):
+ * css/CSSStyleSheet.h:
+ * css/CSSStyleSheet.idl:
+
2016-07-26 George Ruan <[email protected]>
HTMLVideoElement frames do not update on iOS when src is a MediaStream blob
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (203739 => 203740)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-07-26 22:00:20 UTC (rev 203740)
@@ -287,6 +287,14 @@
return nonCharsetRules;
}
+unsigned CSSStyleSheet::deprecatedInsertRule(const String& ruleString, ExceptionCode& ec)
+{
+ if (auto* document = ownerDocument())
+ document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, ASCIILiteral("Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0)."));
+
+ return insertRule(ruleString, 0, ec);
+}
+
unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, ExceptionCode& ec)
{
ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (203739 => 203740)
--- trunk/Source/WebCore/css/CSSStyleSheet.h 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h 2016-07-26 22:00:20 UTC (rev 203740)
@@ -65,6 +65,7 @@
RefPtr<CSSRuleList> cssRules();
unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
+ unsigned deprecatedInsertRule(const String& rule, ExceptionCode&);
void deleteRule(unsigned index, ExceptionCode&);
// IE Extensions
Modified: trunk/Source/WebCore/css/CSSStyleSheet.idl (203739 => 203740)
--- trunk/Source/WebCore/css/CSSStyleSheet.idl 2016-07-26 21:52:27 UTC (rev 203739)
+++ trunk/Source/WebCore/css/CSSStyleSheet.idl 2016-07-26 22:00:20 UTC (rev 203740)
@@ -23,18 +23,18 @@
readonly attribute CSSRule ownerRule;
readonly attribute CSSRuleList cssRules;
- // FIXME: Using "undefined" as default parameter value is wrong.
- [ObjCLegacyUnnamedParameters, RaisesException] unsigned long insertRule(optional DOMString rule = "undefined",
- optional unsigned long index = 0);
- [RaisesException] void deleteRule(optional unsigned long index = 0);
+ [ObjCLegacyUnnamedParameters, RaisesException] unsigned long insertRule(DOMString rule, unsigned long index);
+#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
+ [RaisesException, ImplementedAs=deprecatedInsertRule] unsigned long insertRule(DOMString rule); // Deprecated.
+#endif
+ [RaisesException] void deleteRule(unsigned long index);
+
// IE Extensions
readonly attribute CSSRuleList rules;
- // FIXME: Using "undefined" as default parameter value is wrong.
- [RaisesException] long addRule(optional DOMString selector = "undefined",
- optional DOMString style = "undefined",
- optional unsigned long index);
+ // FIXME: Those operations are WebKit-specific.
+ [RaisesException] long addRule(optional DOMString selector = "undefined", optional DOMString style = "undefined", optional unsigned long index);
[RaisesException] void removeRule(optional unsigned long index = 0);
};