Title: [140839] trunk
Revision
140839
Author
[email protected]
Date
2013-01-25 09:48:54 -0800 (Fri, 25 Jan 2013)

Log Message

Source/WebCore: ScriptController::executeIfJavaScriptURL incorrectly checks viewsource mode.
incorrectly blocks execution based on the frame's viewsource state.
https://bugs.webkit.org/show_bug.cgi?id=101683

Reviewed by Adam Barth.

ScriptController::executeIfJavaScriptURL currently checks whether the
frame in which a '_javascript_:' URL might be executed is in viewsource
mode. This incorrectly handles the case where the viewsource attribute
is added after a document loads: the _frame_ is in viewsource mode, the
_document_ is not. The latter should control execution, not the former.

This patch drops the inViewSourceMode check from executeIfJavaScriptURL
entirely, as the document's viewsource state is checked in
canExecuteScripts, which is already called when the '_javascript_:' URL is
passed to executeScript. The checks should remain centralized there.

Test: http/tests/security/view-source-_javascript_-url-in-document.html

* bindings/ScriptControllerBase.cpp:
(WebCore::ScriptController::executeIfJavaScriptURL):
    Drop the incorrect check against the Frame's viewsource mode. The
    correct check against the Document's viewsource mode is performed
    in canExecuteScripts (which is called via executeScript).

LayoutTests: Merge isViewSource checks in ScriptController::executeIfJavaScriptURL and ScriptController::canExecuteScripts.
https://bugs.webkit.org/show_bug.cgi?id=101683

Reviewed by Adam Barth.

* http/tests/security/view-source-_javascript_-url-in-document-expected.txt: Added.
* http/tests/security/view-source-_javascript_-url-in-document.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140838 => 140839)


--- trunk/LayoutTests/ChangeLog	2013-01-25 17:37:57 UTC (rev 140838)
+++ trunk/LayoutTests/ChangeLog	2013-01-25 17:48:54 UTC (rev 140839)
@@ -1,3 +1,13 @@
+2013-01-25  Mike West  <[email protected]>
+
+        Merge isViewSource checks in ScriptController::executeIfJavaScriptURL and ScriptController::canExecuteScripts.
+        https://bugs.webkit.org/show_bug.cgi?id=101683
+
+        Reviewed by Adam Barth.
+
+        * http/tests/security/view-source-_javascript_-url-in-document-expected.txt: Added.
+        * http/tests/security/view-source-_javascript_-url-in-document.html: Added.
+
 2013-01-25  Erik Arvidsson  <[email protected]>
 
         Unreviewed Chromium rebaseline.

Added: trunk/LayoutTests/http/tests/security/view-source-_javascript_-url-in-document-expected.txt (0 => 140839)


--- trunk/LayoutTests/http/tests/security/view-source-_javascript_-url-in-document-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/view-source-_javascript_-url-in-document-expected.txt	2013-01-25 17:48:54 UTC (rev 140839)
@@ -0,0 +1,4 @@
+ALERT: PASS: Function called.
+Adding 'viewsource' to a frame after a document has loaded should not block _javascript_ URL execution in the already-loaded document.
+
+

Added: trunk/LayoutTests/http/tests/security/view-source-_javascript_-url-in-document.html (0 => 140839)


--- trunk/LayoutTests/http/tests/security/view-source-_javascript_-url-in-document.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/view-source-_javascript_-url-in-document.html	2013-01-25 17:48:54 UTC (rev 140839)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+    </script>
+</head>
+<body>
+    <p>Adding 'viewsource' to a frame after a document has loaded should not
+    block _javascript_ URL execution in the already-loaded document.</p>
+    <iframe srcdoc="
+        <script>
+            window._onload_ = function() {
+                window.parent.document.querySelector('iframe').setAttribute('viewsource', '');
+
+                document.querySelector('a').click();
+
+                alert(calledFunction ? 'PASS: Function called.' : 'FAIL: Function not called.');
+
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            };
+
+            var calledFunction = false;
+            function pass() {
+                calledFunction = true;
+            }
+        </script>
+        <a href=''>Yay!</a>"></iframe>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (140838 => 140839)


--- trunk/Source/WebCore/ChangeLog	2013-01-25 17:37:57 UTC (rev 140838)
+++ trunk/Source/WebCore/ChangeLog	2013-01-25 17:48:54 UTC (rev 140839)
@@ -1,3 +1,30 @@
+2013-01-25  Mike West  <[email protected]>
+
+        ScriptController::executeIfJavaScriptURL incorrectly checks viewsource mode.
+        incorrectly blocks execution based on the frame's viewsource state.
+        https://bugs.webkit.org/show_bug.cgi?id=101683
+
+        Reviewed by Adam Barth.
+
+        ScriptController::executeIfJavaScriptURL currently checks whether the
+        frame in which a '_javascript_:' URL might be executed is in viewsource
+        mode. This incorrectly handles the case where the viewsource attribute
+        is added after a document loads: the _frame_ is in viewsource mode, the
+        _document_ is not. The latter should control execution, not the former.
+
+        This patch drops the inViewSourceMode check from executeIfJavaScriptURL
+        entirely, as the document's viewsource state is checked in
+        canExecuteScripts, which is already called when the '_javascript_:' URL is
+        passed to executeScript. The checks should remain centralized there.
+
+        Test: http/tests/security/view-source-_javascript_-url-in-document.html
+
+        * bindings/ScriptControllerBase.cpp:
+        (WebCore::ScriptController::executeIfJavaScriptURL):
+            Drop the incorrect check against the Frame's viewsource mode. The
+            correct check against the Document's viewsource mode is performed
+            in canExecuteScripts (which is called via executeScript).
+
 2013-01-25  Gustavo Noronha Silva  <[email protected]>
 
         [Soup] Streamline cancellation and client checks

Modified: trunk/Source/WebCore/bindings/ScriptControllerBase.cpp (140838 => 140839)


--- trunk/Source/WebCore/bindings/ScriptControllerBase.cpp	2013-01-25 17:37:57 UTC (rev 140838)
+++ trunk/Source/WebCore/bindings/ScriptControllerBase.cpp	2013-01-25 17:48:54 UTC (rev 140839)
@@ -79,8 +79,7 @@
         return false;
 
     if (!m_frame->page()
-        || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame->document()->url(), eventHandlerPosition().m_line)
-        || m_frame->inViewSourceMode())
+        || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame->document()->url(), eventHandlerPosition().m_line))
         return true;
 
     // We need to hold onto the Frame here because executing script can
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to