Title: [142726] trunk
Revision
142726
Author
morr...@google.com
Date
2013-02-12 23:34:47 -0800 (Tue, 12 Feb 2013)

Log Message

[Internals] setShadowDOMEnabled() shouldn't be used except a few tests.
https://bugs.webkit.org/show_bug.cgi?id=109642

Reviewed by Kent Tamura.

Source/WebCore:

InternalSettings.setShadowDOMEnabled() shouldn't be called after
any relevant DOM bindings are touched. However for fuzzers, it
isn't trivial to regulate its behavior.

This change whitelists the URL of running test for prevent
unintended API calls. This doesn't hurt the Internals usability
since the API is called from just a couple of tests and the number
isn't expected to grow.

Test: fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html

* testing/InternalSettings.cpp:
(WebCore::urlIsWhitelisted):
(WebCore):
(WebCore::InternalSettings::setShadowDOMEnabled):

LayoutTests:

* fast/dom/shadow/shadow-dom-enabled-flag-whitelist-expected.txt: Added.
* fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142725 => 142726)


--- trunk/LayoutTests/ChangeLog	2013-02-13 07:24:02 UTC (rev 142725)
+++ trunk/LayoutTests/ChangeLog	2013-02-13 07:34:47 UTC (rev 142726)
@@ -1,3 +1,13 @@
+2013-02-12  Hajime Morrita  <morr...@google.com>
+
+        [Internals] setShadowDOMEnabled() shouldn't be used except a few tests.
+        https://bugs.webkit.org/show_bug.cgi?id=109642
+
+        Reviewed by Kent Tamura.
+
+        * fast/dom/shadow/shadow-dom-enabled-flag-whitelist-expected.txt: Added.
+        * fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html: Added.
+
 2013-02-12  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: Introduce version controller to migrate settings versions.

Added: trunk/LayoutTests/fast/dom/shadow/shadow-dom-enabled-flag-whitelist-expected.txt (0 => 142726)


--- trunk/LayoutTests/fast/dom/shadow/shadow-dom-enabled-flag-whitelist-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-dom-enabled-flag-whitelist-expected.txt	2013-02-13 07:34:47 UTC (rev 142726)
@@ -0,0 +1,10 @@
+Ensure that setShadowDOMEnabled() is only allowed for a set of tests.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.internals.settings.setShadowDOMEnabled(false) threw exception Error: InvalidAccessError: DOM Exception 15.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html (0 => 142726)


--- trunk/LayoutTests/fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html	2013-02-13 07:34:47 UTC (rev 142726)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Ensure that setShadowDOMEnabled() is only allowed for a set of tests.")
+shouldThrow("window.internals.settings.setShadowDOMEnabled(false)", "'Error: InvalidAccessError: DOM Exception 15'");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (142725 => 142726)


--- trunk/Source/WebCore/ChangeLog	2013-02-13 07:24:02 UTC (rev 142725)
+++ trunk/Source/WebCore/ChangeLog	2013-02-13 07:34:47 UTC (rev 142726)
@@ -1,3 +1,26 @@
+2013-02-12  Hajime Morrita  <morr...@google.com>
+
+        [Internals] setShadowDOMEnabled() shouldn't be used except a few tests.
+        https://bugs.webkit.org/show_bug.cgi?id=109642
+
+        Reviewed by Kent Tamura.
+
+        InternalSettings.setShadowDOMEnabled() shouldn't be called after
+        any relevant DOM bindings are touched. However for fuzzers, it
+        isn't trivial to regulate its behavior.
+
+        This change whitelists the URL of running test for prevent
+        unintended API calls. This doesn't hurt the Internals usability
+        since the API is called from just a couple of tests and the number
+        isn't expected to grow.
+
+        Test: fast/dom/shadow/shadow-dom-enabled-flag-whitelist.html
+
+        * testing/InternalSettings.cpp:
+        (WebCore::urlIsWhitelisted):
+        (WebCore):
+        (WebCore::InternalSettings::setShadowDOMEnabled):
+
 2013-02-12  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: Introduce version controller to migrate settings versions.

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (142725 => 142726)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2013-02-13 07:24:02 UTC (rev 142725)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2013-02-13 07:34:47 UTC (rev 142726)
@@ -195,10 +195,22 @@
     settings()->setMockScrollbarsEnabled(enabled);
 }
 
+static bool urlIsWhitelistedForSetShadowDOMEnabled(const String& url)
+{
+    // This check is just for preventing fuzzers from crashing because of unintended API calls.
+    // You can list your test if needed.
+    return notFound != url.find("fast/dom/shadow/content-shadow-unknown.html")
+        || notFound != url.find("fast/dom/shadow/insertion-points-with-shadow-disabled.html");
+}
+
 void InternalSettings::setShadowDOMEnabled(bool enabled, ExceptionCode& ec)
 {
+    if (!urlIsWhitelistedForSetShadowDOMEnabled(page()->mainFrame()->document()->url().string())) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
 #if ENABLE(SHADOW_DOM)
-    UNUSED_PARAM(ec);
     RuntimeEnabledFeatures::setShadowDOMEnabled(enabled);
 #else
     // Even SHADOW_DOM is off, InternalSettings allows setShadowDOMEnabled(false) to
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to