Diff
Modified: branches/safari-601.1-branch/LayoutTests/ChangeLog (186928 => 186929)
--- branches/safari-601.1-branch/LayoutTests/ChangeLog 2015-07-17 05:32:19 UTC (rev 186928)
+++ branches/safari-601.1-branch/LayoutTests/ChangeLog 2015-07-17 05:32:26 UTC (rev 186929)
@@ -1,3 +1,31 @@
+2015-07-16 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r186807. rdar://problem/21782350
+
+ 2015-07-14 Alex Christensen <achristen...@webkit.org>
+
+ [Content Extensions] Fix if-domain and unless-domain when loading main documents.
+ https://bugs.webkit.org/show_bug.cgi?id=146868
+
+ Reviewed by Benjamin Poulain.
+
+ * http/tests/contentextensions/block-everything-if-domain-expected.txt: Added.
+ * http/tests/contentextensions/block-everything-if-domain.html: Added.
+ * http/tests/contentextensions/block-everything-if-domain.html.json: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-expected.txt: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-iframe.html: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-iframe.html.json: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-redirect.php: Added.
+ * http/tests/contentextensions/block-everything-unless-domain-redirect.php.json: Added.
+ * http/tests/contentextensions/block-everything-unless-domain.html: Added.
+ * http/tests/contentextensions/block-everything-unless-domain.html.json: Added.
+ * http/tests/contentextensions/main-resource-redirect-blocked-expected.txt:
+ * http/tests/contentextensions/resources/block-everything-unless-domain-helper.html: Added.
+ * http/tests/contentextensions/resources/should-load.html: Added.
+ * http/tests/contentextensions/resources/should-not-load.html: Added.
+
2015-07-12 Babak Shafiei <bshaf...@apple.com>
Merge r186741.
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-everything-if-domain.html from loading a resource from http://127.0.0.1:8000/contentextensions/block-everything-if-domain.html
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1 @@
+about:blank should load instead of this.
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,11 @@
+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "if-domain": ["127.0.0.1"]
+ }
+ }
+]
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: line 18: http://127.0.0.1:8000/contentextensions/resources/block-everything-unless-domain-helper.html
+CONSOLE MESSAGE: line 5: helper loaded
+CONSOLE MESSAGE: line 7: Content blocker prevented frame displaying http://localhost:8000/contentextensions/resources/should-not-load.html from loading a resource from http://localhost:8000/contentextensions/resources/should-not-load.html
+CONSOLE MESSAGE: line 15: successfully blocked load from localhost
+
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,8 @@
+CONSOLE MESSAGE: line 15: The page loaded successfully.
+CONSOLE MESSAGE: line 3: This page should load.
+
+
+--------
+Frame: 'iframe'
+--------
+This page should load.
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,23 @@
+<head>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.dumpChildFramesAsText();
+ testRunner.waitUntilDone();
+}
+function iframeLoaded()
+{
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+function bodyLoaded()
+{
+ console.log("The page loaded successfully.");
+ document.getElementById("iframe")._onload_ = iframeLoaded;
+ document.getElementById("iframe").src = ""
+}
+</script>
+</head>
+<body _onload_="bodyLoaded()">
+<iframe id="iframe"></iframe>
+</body>
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,11 @@
+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "unless-domain": ["127.0.0.1"]
+ }
+ }
+]
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1 @@
+CONSOLE MESSAGE: Content blocker prevented frame displaying http://localhost/contentextensions/resources/should-not-load.html from loading a resource from http://localhost/contentextensions/resources/should-not-load.html
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,4 @@
+<?php
+ header('Location: http://localhost/contentextensions/resources/should-not-load.html');
+ header('HTTP/1.0 302 Found');
+?>
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,11 @@
+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "unless-domain": ["127.0.0.1"]
+ }
+ }
+]
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,31 @@
+<script>
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ testRunner.setCanOpenWindows(true);
+ testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+
+var maxEventLoopRuns = 50;
+function helperLoaded () {
+ if (!maxEventLoopRuns) {
+ console.log("blocking load failed");
+ testRunner.notifyDone();
+ } else if (helper.location == "about:blank") {
+ console.log("successfully blocked load from localhost");
+ testRunner.notifyDone();
+ } else {
+ console.log(helper.location);
+ setTimeout(helperLoaded, 1);
+ maxEventLoopRuns--;
+ }
+}
+
+var helper = window.open("resources/block-everything-unless-domain-helper.html");
+if (helper)
+ helper.addEventListener('load', helperLoaded);
+else {
+ console.log("opening window failed");
+ testRunner.notifyDone();
+}
+</script>
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,11 @@
+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "unless-domain": ["127.0.0.1"]
+ }
+ }
+]
Modified: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt (186928 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt 2015-07-17 05:32:19 UTC (rev 186928)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt 2015-07-17 05:32:26 UTC (rev 186929)
@@ -1 +1 @@
-CONSOLE MESSAGE: Content blocker prevented frame displaying about:blank from loading a resource from http://127.0.0.1:8000/contentextensions/resources/main-resource-redirect-blocked-target.html
+CONSOLE MESSAGE: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/resources/main-resource-redirect-blocked-target.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/main-resource-redirect-blocked-target.html
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,13 @@
+<head>
+<script>
+function bodyLoaded()
+{
+ console.log("helper loaded");
+ var anchor = document.getElementById("anchor");
+ anchor.click();
+}
+</script>
+</head>
+<body _onload_="bodyLoaded()">
+<a id="anchor" href="" this should take you to a document that doesn't load with the content extension.</a>
+</body>
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/should-load.html (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/should-load.html (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/should-load.html 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,4 @@
+This page should load.
+<script>
+ console.log("This page should load.");
+</script>
Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/should-not-load.html (0 => 186929)
--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/should-not-load.html (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/resources/should-not-load.html 2015-07-17 05:32:26 UTC (rev 186929)
@@ -0,0 +1,4 @@
+This page should not load.
+<script>
+ console.log("This page should not load.");
+</script>
Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (186928 => 186929)
--- branches/safari-601.1-branch/Source/WebCore/ChangeLog 2015-07-17 05:32:19 UTC (rev 186928)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog 2015-07-17 05:32:26 UTC (rev 186929)
@@ -1,5 +1,25 @@
2015-07-16 Matthew Hanson <matthew_han...@apple.com>
+ Merge r186807. rdar://problem/21782350
+
+ 2015-07-14 Alex Christensen <achristen...@webkit.org>
+
+ [Content Extensions] Fix if-domain and unless-domain when loading main documents.
+ https://bugs.webkit.org/show_bug.cgi?id=146868
+
+ Reviewed by Benjamin Poulain.
+
+ Tests: http/tests/contentextensions/block-everything-if-domain.html
+ http/tests/contentextensions/block-everything-unless-domain-iframe.html
+ http/tests/contentextensions/block-everything-unless-domain-redirect.php
+ http/tests/contentextensions/block-everything-unless-domain.html
+
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
+ If we are loading a new main document, use that main document url as the main document url for domain comparison.
+
+2015-07-16 Matthew Hanson <matthew_han...@apple.com>
+
Merge r186786. rdar://problem/9222837
2015-07-13 Simon Fraser <simon.fra...@apple.com>
Modified: branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (186928 => 186929)
--- branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2015-07-17 05:32:19 UTC (rev 186928)
+++ branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2015-07-17 05:32:26 UTC (rev 186929)
@@ -167,10 +167,14 @@
Document* currentDocument = nullptr;
URL mainDocumentURL;
- if (initiatingDocumentLoader.frame()) {
- currentDocument = initiatingDocumentLoader.frame()->document();
+ if (Frame* frame = initiatingDocumentLoader.frame()) {
+ currentDocument = frame->document();
- if (Document* mainDocument = initiatingDocumentLoader.frame()->mainFrame().document())
+ if (initiatingDocumentLoader.isLoadingMainResource()
+ && frame->isMainFrame()
+ && resourceType == ResourceType::Document)
+ mainDocumentURL = request.url();
+ else if (Document* mainDocument = frame->mainFrame().document())
mainDocumentURL = mainDocument->url();
}