Title: [186228] trunk
Revision
186228
Author
beid...@apple.com
Date
2015-07-02 11:33:23 -0700 (Thu, 02 Jul 2015)

Log Message

[Content Extensions] Block synchronous XMLHTTPRequest.
<rdar://problem/21573006> and https://bugs.webkit.org/show_bug.cgi?id=146271

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/contentextensions/sync-xhr-blocked.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously): If content blocked, set up an error, clear
  the response, and clear the response data.

LayoutTests:

* http/tests/contentextensions/sync-xhr-blocked-expected.txt: Added.
* http/tests/contentextensions/sync-xhr-blocked.html: Added.
* http/tests/contentextensions/sync-xhr-blocked.html.json: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (186227 => 186228)


--- trunk/LayoutTests/ChangeLog	2015-07-02 17:31:57 UTC (rev 186227)
+++ trunk/LayoutTests/ChangeLog	2015-07-02 18:33:23 UTC (rev 186228)
@@ -1,3 +1,14 @@
+2015-07-02  Brady Eidson  <beid...@apple.com>
+
+        [Content Extensions] Block synchronous XMLHTTPRequest.
+        <rdar://problem/21573006> and https://bugs.webkit.org/show_bug.cgi?id=146271
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/contentextensions/sync-xhr-blocked-expected.txt: Added.
+        * http/tests/contentextensions/sync-xhr-blocked.html: Added.
+        * http/tests/contentextensions/sync-xhr-blocked.html.json: Added.
+
 2015-07-02  Alex Christensen  <achristen...@webkit.org>
 
         Skip new web timing test on platforms without web timing.

Added: trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked-expected.txt (0 => 186228)


--- trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked-expected.txt	2015-07-02 18:33:23 UTC (rev 186228)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 21: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/sync-xhr-blocked.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
+CONSOLE MESSAGE: line 21: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js. 
+Synchronous status: 0, readyState:1, responseText: 
+Synchronous status: 0, readyState:4, responseText: 
+Synchronous error: Error: NETWORK_ERR: XMLHttpRequest Exception 101
+

Added: trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked.html (0 => 186228)


--- trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked.html	2015-07-02 18:33:23 UTC (rev 186228)
@@ -0,0 +1,32 @@
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function log(text) {
+    document.body.appendChild(document.createTextNode(text));
+    document.body.appendChild(document.createElement("br"));
+}
+
+function runTest() {
+    var xhr = new XMLHttpRequest();
+    xhr._onreadystatechange_ = function() {
+        log("Synchronous status: " + xhr.status + ", readyState:" + xhr.readyState + ", responseText: " + xhr.responseText);
+    }
+    
+    xhr.open("GET", "resources/url-blocking-test.js", false);
+    try {
+        xhr.send();
+    } catch (error) {
+        log("Synchronous error: " + error);
+    }
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>

Added: trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked.html.json (0 => 186228)


--- trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked.html.json	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/sync-xhr-blocked.html.json	2015-07-02 18:33:23 UTC (rev 186228)
@@ -0,0 +1,10 @@
+[
+    {
+        "action": {
+            "type": "block"
+        },
+        "trigger": {
+            "url-filter": "url-blocking-test"
+        }
+    }
+]

Modified: trunk/Source/WebCore/ChangeLog (186227 => 186228)


--- trunk/Source/WebCore/ChangeLog	2015-07-02 17:31:57 UTC (rev 186227)
+++ trunk/Source/WebCore/ChangeLog	2015-07-02 18:33:23 UTC (rev 186228)
@@ -1,3 +1,16 @@
+2015-07-02  Brady Eidson  <beid...@apple.com>
+
+        [Content Extensions] Block synchronous XMLHTTPRequest.
+        <rdar://problem/21573006> and https://bugs.webkit.org/show_bug.cgi?id=146271
+
+        Reviewed by Alex Christensen.
+
+        Test: http/tests/contentextensions/sync-xhr-blocked.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadResourceSynchronously): If content blocked, set up an error, clear
+          the response, and clear the response data.
+
 2015-07-01  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Aggregate profile call information on the backend to drastically reduce profile sizes

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (186227 => 186228)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2015-07-02 17:31:57 UTC (rev 186227)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2015-07-02 18:33:23 UTC (rev 186228)
@@ -93,6 +93,7 @@
 #include "PolicyChecker.h"
 #include "ProgressTracker.h"
 #include "ResourceHandle.h"
+#include "ResourceLoadInfo.h"
 #include "ResourceRequest.h"
 #include "SVGDocument.h"
 #include "SVGLocatable.h"
@@ -111,6 +112,7 @@
 #include "Settings.h"
 #include "SubframeLoader.h"
 #include "TextResourceDecoder.h"
+#include "UserContentController.h"
 #include "WindowFeatures.h"
 #include "XMLDocumentParser.h"
 #include <wtf/CurrentTime.h>
@@ -2691,7 +2693,24 @@
     ResourceRequest newRequest(initialRequest);
     requestFromDelegate(newRequest, identifier, error);
 
+#if ENABLE(CONTENT_EXTENSIONS)
     if (error.isNull()) {
+        if (m_documentLoader) {
+            if (auto* page = m_frame.page()) {
+                if (auto* controller = page->userContentController())
+                    controller->processContentExtensionRulesForLoad(*page, newRequest, ResourceType::Raw, *m_documentLoader);
+            }
+        }
+        
+        if (newRequest.isNull()) {
+            error = ResourceError(errorDomainWebKitInternal, 0, initialRequest.url().string(), emptyString());
+            response = ResourceResponse();
+            data = ""
+        }
+    }
+#endif
+
+    if (error.isNull()) {
         ASSERT(!newRequest.isNull());
 
         if (!documentLoader()->applicationCacheHost()->maybeLoadSynchronously(newRequest, error, response, data)) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to