Title: [135903] trunk
Revision
135903
Author
[email protected]
Date
2012-11-27 12:44:03 -0800 (Tue, 27 Nov 2012)

Log Message

Log to console when autofocus is blocked by sandbox attribute.
https://bugs.webkit.org/show_bug.cgi?id=103255

Reviewed by Ojan Vafai.

Source/WebCore:

Adding a short log message when autofocus is blocked by a document's
sandbox flags, as it's currently a black box.

Test: fast/forms/autofocus-in-sandbox-without-allow-scripts.html

* html/HTMLFormControlElement.cpp:
(WebCore::shouldAutofocus):

LayoutTests:

* fast/forms/autofocus-in-sandbox-without-allow-scripts-expected.txt: Added.
* fast/forms/autofocus-in-sandbox-without-allow-scripts.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (135902 => 135903)


--- trunk/LayoutTests/ChangeLog	2012-11-27 20:40:38 UTC (rev 135902)
+++ trunk/LayoutTests/ChangeLog	2012-11-27 20:44:03 UTC (rev 135903)
@@ -1,3 +1,13 @@
+2012-11-27  Mike West  <[email protected]>
+
+        Log to console when autofocus is blocked by sandbox attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=103255
+
+        Reviewed by Ojan Vafai.
+
+        * fast/forms/autofocus-in-sandbox-without-allow-scripts-expected.txt: Added.
+        * fast/forms/autofocus-in-sandbox-without-allow-scripts.html: Added.
+
 2012-11-27  Robert Kroeger  <[email protected]>
 
         Unreviewed gardening: ImageOnlyFailure in fast/canvas/font-update.html

Added: trunk/LayoutTests/fast/frames/sandboxed-iframe-autofocus-denied-expected.txt (0 => 135903)


--- trunk/LayoutTests/fast/frames/sandboxed-iframe-autofocus-denied-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/frames/sandboxed-iframe-autofocus-denied-expected.txt	2012-11-27 20:44:03 UTC (rev 135903)
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: Blocked autofocusing on a form control because the form's frame is sandboxed and the 'allow-script' permission is not set.
+CONSOLE MESSAGE: line 13: PASS: The input element is not focused.
+This test passes if the input element in the sandboxed frame is not automatically focused upon, as it should be blocked by the sandboxed scripts flag. A console warning to that effect should also be present.
+
+

Added: trunk/LayoutTests/fast/frames/sandboxed-iframe-autofocus-denied.html (0 => 135903)


--- trunk/LayoutTests/fast/frames/sandboxed-iframe-autofocus-denied.html	                        (rev 0)
+++ trunk/LayoutTests/fast/frames/sandboxed-iframe-autofocus-denied.html	2012-11-27 20:44:03 UTC (rev 135903)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function test() {
+            activeTag = document.querySelector('iframe').contentWindow.document.activeElement.tagName;
+            if (activeTag == "INPUT")
+                console.log("FAIL: The input element is focused.");
+            else
+                console.log("PASS: The input element is not focused.");
+        }
+    </script>
+</head>
+<body>
+    <p>This test passes if the input element in the sandboxed frame is not
+    automatically focused upon, as it should be blocked by the sandboxed
+    scripts flag. A console warning to that effect should also be present.</p>
+    <iframe sandbox="allow-same-origin"
+            _onload_="test()"
+            srcdoc="<input autofocus onfocus>"></iframe>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (135902 => 135903)


--- trunk/Source/WebCore/ChangeLog	2012-11-27 20:40:38 UTC (rev 135902)
+++ trunk/Source/WebCore/ChangeLog	2012-11-27 20:44:03 UTC (rev 135903)
@@ -1,3 +1,18 @@
+2012-11-27  Mike West  <[email protected]>
+
+        Log to console when autofocus is blocked by sandbox attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=103255
+
+        Reviewed by Ojan Vafai.
+
+        Adding a short log message when autofocus is blocked by a document's
+        sandbox flags, as it's currently a black box.
+
+        Test: fast/forms/autofocus-in-sandbox-without-allow-scripts.html
+
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::shouldAutofocus):
+
 2012-11-27  Dean Jackson  <[email protected]>
 
         Attempted build fix after http://trac.webkit.org/changeset/135888.

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (135902 => 135903)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2012-11-27 20:40:38 UTC (rev 135902)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2012-11-27 20:44:03 UTC (rev 135903)
@@ -172,8 +172,11 @@
         return false;
     if (element->document()->ignoreAutofocus())
         return false;
-    if (element->document()->isSandboxed(SandboxAutomaticFeatures))
+    if (element->document()->isSandboxed(SandboxAutomaticFeatures)) {
+        // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
+        element->document()->addConsoleMessage(HTMLMessageSource, LogMessageType, ErrorMessageLevel, "Blocked autofocusing on a form control because the form's frame is sandboxed and the 'allow-script' permission is not set.");
         return false;
+    }
     if (element->hasAutofocused())
         return false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to