<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[186807] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/186807">186807</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-07-14 10:36:54 -0700 (Tue, 14 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Content Extensions] Fix if-domain and unless-domain when loading main documents.
https://bugs.webkit.org/show_bug.cgi?id=146868
Patch by Alex Christensen <achristensen@webkit.org> on 2015-07-14
Reviewed by Benjamin Poulain.
Source/WebCore:
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.
LayoutTests:
* 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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsmainresourceredirectblockedexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingifdomainexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingifdomainhtml">trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingifdomainhtmljson">trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainiframeexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainiframehtml">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainiframehtmljson">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainredirectexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainredirectphp">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainredirectphpjson">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainhtml">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainhtmljson">trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsresourcesblockeverythingunlessdomainhelperhtml">trunk/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsresourcesshouldloadhtml">trunk/LayoutTests/http/tests/contentextensions/resources/should-load.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsresourcesshouldnotloadhtml">trunk/LayoutTests/http/tests/contentextensions/resources/should-not-load.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (186806 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-07-14 17:26:11 UTC (rev 186806)
+++ trunk/LayoutTests/ChangeLog        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-07-14 Alex Christensen <achristensen@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.
+
</ins><span class="cx"> 2015-07-05 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> DOM4: prepend, append, before, after & replace
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingifdomainexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain-expected.txt        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+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
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingifdomainhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+about:blank should load instead of this.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingifdomainhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-if-domain.html.json        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "if-domain": ["127.0.0.1"]
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-expected.txt        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainiframeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe-expected.txt        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+CONSOLE MESSAGE: line 15: The page loaded successfully.
+CONSOLE MESSAGE: line 3: This page should load.
+
+
+--------
+Frame: 'iframe'
+--------
+This page should load.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainiframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+<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 = "http://localhost:8000/contentextensions/resources/should-load.html";
+}
+</script>
+</head>
+<body onload="bodyLoaded()">
+<iframe id="iframe"></iframe>
+</body>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainiframehtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-iframe.html.json        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "unless-domain": ["127.0.0.1"]
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainredirectexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect-expected.txt        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+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
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainredirectphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+<?php
+ header('Location: http://localhost/contentextensions/resources/should-not-load.html');
+ header('HTTP/1.0 302 Found');
+?>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainredirectphpjson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain-redirect.php.json        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "unless-domain": ["127.0.0.1"]
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+<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>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockeverythingunlessdomainhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-everything-unless-domain.html.json        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": ".*",
+ "unless-domain": ["127.0.0.1"]
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsmainresourceredirectblockedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt (186806 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt        2015-07-14 17:26:11 UTC (rev 186806)
+++ trunk/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked-expected.txt        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -1 +1 @@
</span><del>-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
</del><ins>+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
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsresourcesblockeverythingunlessdomainhelperhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/resources/block-everything-unless-domain-helper.html        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<head>
+<script>
+function bodyLoaded()
+{
+ console.log("helper loaded");
+ var anchor = document.getElementById("anchor");
+        anchor.click();
+}
+</script>
+</head>
+<body onload="bodyLoaded()">
+<a id="anchor" href="http://localhost:8000/contentextensions/resources/should-not-load.html">Clicking this should take you to a document that doesn't load with the content extension.</a>
+</body>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsresourcesshouldloadhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/resources/should-load.html (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/resources/should-load.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/resources/should-load.html        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+This page should load.
+<script>
+ console.log("This page should load.");
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsresourcesshouldnotloadhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/resources/should-not-load.html (0 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/resources/should-not-load.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/resources/should-not-load.html        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+This page should not load.
+<script>
+ console.log("This page should not load.");
+</script>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (186806 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-14 17:26:11 UTC (rev 186806)
+++ trunk/Source/WebCore/ChangeLog        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-07-14 Alex Christensen <achristensen@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.
+
</ins><span class="cx"> 2015-07-05 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> DOM4: prepend, append, before, after & replace
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (186806 => 186807)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-07-14 17:26:11 UTC (rev 186806)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-07-14 17:36:54 UTC (rev 186807)
</span><span class="lines">@@ -167,10 +167,14 @@
</span><span class="cx"> Document* currentDocument = nullptr;
</span><span class="cx"> URL mainDocumentURL;
</span><span class="cx">
</span><del>- if (initiatingDocumentLoader.frame()) {
- currentDocument = initiatingDocumentLoader.frame()->document();
</del><ins>+ if (Frame* frame = initiatingDocumentLoader.frame()) {
+ currentDocument = frame->document();
</ins><span class="cx">
</span><del>- if (Document* mainDocument = initiatingDocumentLoader.frame()->mainFrame().document())
</del><ins>+ if (initiatingDocumentLoader.isLoadingMainResource()
+ && frame->isMainFrame()
+ && resourceType == ResourceType::Document)
+ mainDocumentURL = request.url();
+ else if (Document* mainDocument = frame->mainFrame().document())
</ins><span class="cx"> mainDocumentURL = mainDocument->url();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>