<!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>[204127] 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/204127">204127</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-04 11:07:45 -0700 (Thu, 04 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Content Blocker cannot block WebSocket connections
https://bugs.webkit.org/show_bug.cgi?id=160159
Patch by Alex Christensen <achristensen@webkit.org> on 2016-08-04
Reviewed by Brady Eidson.
Source/WebCore:
Tests: http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php
http/tests/websocket/tests/hybi/contentextensions/block-cookies.php
http/tests/websocket/tests/hybi/contentextensions/block-worker.html
http/tests/websocket/tests/hybi/contentextensions/block.html
http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html
http/tests/websocket/tests/hybi/contentextensions/display-none.html
http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html
http/tests/websocket/tests/hybi/contentextensions/upgrade.html
* Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
(WebCore::ThreadableWebSocketChannelClientWrapper::didUpgradeURL):
(WebCore::ThreadableWebSocketChannelClientWrapper::suspend):
* Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::didClose):
(WebCore::WebSocket::didUpgradeURL):
(WebCore::WebSocket::getFramingOverhead):
* Modules/websockets/WebSocket.h:
Added didUpgradeURL to WebSocketChannelClient so the WebSocketChannel can tell the WebSocket
that it has upgraded a ws: url to a wss: url.
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::~WebSocketChannel):
(WebCore::WebSocketChannel::connect):
If content extensions are being used, run the URL through the content extension and apply its actions
before connecting the WebSocket. This is done in WebSocketChannel instead of WebSocket like the CSP checks
because we need access to the Document in order to get access to the main document's URL for if-domain and
unless-domain rules, and to apply any display:none css to the Document.
(WebCore::WebSocketChannel::disconnect):
* Modules/websockets/WebSocketChannelClient.h:
(WebCore::WebSocketChannelClient::~WebSocketChannelClient):
(WebCore::WebSocketChannelClient::WebSocketChannelClient):
(WebCore::WebSocketChannelClient::didConnect):
(WebCore::WebSocketChannelClient::didReceiveMessage):
(WebCore::WebSocketChannelClient::didReceiveBinaryData):
(WebCore::WebSocketChannelClient::didReceiveMessageError):
(WebCore::WebSocketChannelClient::didUpdateBufferedAmount):
(WebCore::WebSocketChannelClient::didStartClosingHandshake):
(WebCore::WebSocketChannelClient::didClose):
Made WebSocketChannelClient purely virtual to avoid accidentally making an implementation that is missing functionality.
(WebCore::WebSocketChannelClient::didUpgradeURL): Added.
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
(WebCore::WebSocketHandshake::WebSocketHandshake):
(WebCore::WebSocketHandshake::clientOrigin):
(WebCore::WebSocketHandshake::clientLocation):
(WebCore::WebSocketHandshake::clientHandshakeMessage):
Only put cookies on the WebSocket's handshake if we are allowed to use cookies.
(WebCore::WebSocketHandshake::clientHandshakeRequest):
A WebSocketHandshake always has a Document* for its ScriptExecutionContext, so I replaced m_context with
m_document and removed a suspicious-looking check for is<Document> that turned out to not be suspicious at all.
(WebCore::WebSocketHandshake::reset):
(WebCore::WebSocketHandshake::clearDocument):
(WebCore::WebSocketHandshake::readServerHandshake):
(WebCore::WebSocketHandshake::clearScriptExecutionContext): Deleted.
* Modules/websockets/WebSocketHandshake.h:
* Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveMessageError):
(WebCore::WorkerThreadableWebSocketChannel::Peer::didUpgradeURL):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::Bridge):
* Modules/websockets/WorkerThreadableWebSocketChannel.h:
* contentextensions/ContentExtensionActions.h:
Before this change we would pass a ResourceRequest as a parameter to the content extension engine.
The ResourceRequest would be used to get the URL, and it would be modified by possibly disabling cookies
or making the URL https. Any display:none CSS rules added were put into the Document through the DocumentLoader.
The only information it needed to return was whether the load was blocked.
To make content extensions work with WebSockets, we need to pass a URL as a parameter instead of a ResourceRequest
because there is no ResourceRequest with WebSockets, only a URL. We can still put CSS rules in through the DocumentLoader,
but the rest of the actions need to be returned through the return value, which is then processed by the callers.
BlockedStatus is now a struct containing a set of actions to apply, and applyBlockedStatusToRequest is a helper function
that applies the actions to the ResourceRequests we have at all previously existing call sites of processContentExtensionRulesForLoad.
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::globalDisplayNoneStyleSheet):
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
(WebCore::ContentExtensions::ContentExtensionsBackend::displayNoneCSSRule):
(WebCore::ContentExtensions::applyBlockedStatusToRequest):
* contentextensions/ContentExtensionsBackend.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::loadResource):
Here, we also only had a URL. Before, we were making a ResourceRequest from the URL just for the content extension engine,
but now we can just pass the URL.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously):
* loader/PingLoader.cpp:
(WebCore::processContentExtensionRulesForLoad):
(WebCore::PingLoader::loadImage):
(WebCore::PingLoader::sendPing):
(WebCore::PingLoader::sendViolationReport):
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequestInternal):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
* page/UserContentProvider.cpp:
(WebCore::contentExtensionsEnabled):
(WebCore::UserContentProvider::processContentExtensionRulesForLoad):
(WebCore::UserContentProvider::actionsForResourceLoad):
* page/UserContentProvider.h:
LayoutTests:
* http/tests/contentextensions/make-https-expected.txt:
Rebased to reflect slight change in console logged messages which contain the same information.
* http/tests/websocket/tests/hybi/contentextensions: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-cookies-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-cookies.php: Copied from LayoutTests/http/tests/websocket/tests/hybi/httponly-cookie.pl.
* http/tests/websocket/tests/hybi/contentextensions/block-cookies.php.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-worker-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-worker.html: Added.
* http/tests/websocket/tests/hybi/contentextensions/block-worker.html.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/block.html: Added.
* http/tests/websocket/tests/hybi/contentextensions/block.html.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/display-none-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/display-none-worker-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html: Added.
* http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/display-none.html: Added.
* http/tests/websocket/tests/hybi/contentextensions/display-none.html.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/resources: Added.
* http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js: Added.
* http/tests/websocket/tests/hybi/contentextensions/resources/block-worker.js: Added.
* http/tests/websocket/tests/hybi/contentextensions/resources/display-none-worker.js: Added.
* http/tests/websocket/tests/hybi/contentextensions/resources/echo-cookie_wsh.py: Copied from LayoutTests/http/tests/websocket/tests/hybi/echo-cookie_wsh.py.
* http/tests/websocket/tests/hybi/contentextensions/resources/echo_wsh.py: Added.
* http/tests/websocket/tests/hybi/contentextensions/resources/upgrade-worker.js: Added.
* http/tests/websocket/tests/hybi/contentextensions/upgrade-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/upgrade-worker-expected.txt: Added.
* http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html: Added.
* http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html.json: Added.
* http/tests/websocket/tests/hybi/contentextensions/upgrade.html: Added.
* http/tests/websocket/tests/hybi/contentextensions/upgrade.html.json: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsmakehttpsexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2TestExpectations">trunk/LayoutTests/platform/mac-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsThreadableWebSocketChannelClientWrappercpp">trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsThreadableWebSocketChannelClientWrapperh">trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketcpp">trunk/Source/WebCore/Modules/websockets/WebSocket.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketh">trunk/Source/WebCore/Modules/websockets/WebSocket.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketChannelcpp">trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketChannelClienth">trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketHandshakecpp">trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWebSocketHandshakeh">trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWorkerThreadableWebSocketChannelcpp">trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebsocketsWorkerThreadableWebSocketChannelh">trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionActionsh">trunk/Source/WebCore/contentextensions/ContentExtensionActions.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendh">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderPingLoadercpp">trunk/Source/WebCore/loader/PingLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadercpp">trunk/Source/WebCore/loader/ResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepageUserContentProvidercpp">trunk/Source/WebCore/page/UserContentProvider.cpp</a></li>
<li><a href="#trunkSourceWebCorepageUserContentProviderh">trunk/Source/WebCore/page/UserContentProvider.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/</li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesworkerexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesworkerphp">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesworkerphpjson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php.json</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesphp">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesphpjson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php.json</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockworkerexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockworkerhtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockworkerhtmljson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockhtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockhtmljson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneworkerexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneworkerhtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneworkerhtmljson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynonehtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynonehtmljson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html.json</a></li>
<li>trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/</li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesblockcookiesworkerjs">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesblockworkerjs">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-worker.js</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesdisplaynoneworkerjs">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/display-none-worker.js</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesechocookie_wshpy">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo-cookie_wsh.py</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesecho_wshpy">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo_wsh.py</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesupgradeworkerjs">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/upgrade-worker.js</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeworkerexpectedtxt">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeworkerhtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeworkerhtmljson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradehtml">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html</a></li>
<li><a href="#trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradehtmljson">trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html.json</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/LayoutTests/ChangeLog        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-08-04 Alex Christensen <achristensen@webkit.org>
+
+ Content Blocker cannot block WebSocket connections
+ https://bugs.webkit.org/show_bug.cgi?id=160159
+
+ Reviewed by Brady Eidson.
+
+ * http/tests/contentextensions/make-https-expected.txt:
+ Rebased to reflect slight change in console logged messages which contain the same information.
+ * http/tests/websocket/tests/hybi/contentextensions: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies.php: Copied from LayoutTests/http/tests/websocket/tests/hybi/httponly-cookie.pl.
+ * http/tests/websocket/tests/hybi/contentextensions/block-cookies.php.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-worker-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-worker.html: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block-worker.html.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block.html: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/block.html.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/display-none-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/display-none-worker-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/display-none.html: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/display-none.html.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/block-worker.js: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/display-none-worker.js: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/echo-cookie_wsh.py: Copied from LayoutTests/http/tests/websocket/tests/hybi/echo-cookie_wsh.py.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/echo_wsh.py: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/resources/upgrade-worker.js: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/upgrade-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/upgrade-worker-expected.txt: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html.json: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/upgrade.html: Added.
+ * http/tests/websocket/tests/hybi/contentextensions/upgrade.html.json: Added.
+
</ins><span class="cx"> 2016-08-04 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> [[Prototype]] property of an interface object for a callback interface must be the Object.prototype object
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/LayoutTests/TestExpectations        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -696,6 +696,7 @@
</span><span class="cx">
</span><span class="cx"> # Content extensions are Mac-WK2-only for now
</span><span class="cx"> http/tests/contentextensions [ Skip ]
</span><ins>+http/tests/websocket/tests/hybi/contentextensions [ Skip ]
</ins><span class="cx">
</span><span class="cx"> webkit.org/b/149072 svg/animations/svgboolean-animation-1.html [ Pass Failure ]
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsmakehttpsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -4,13 +4,13 @@
</span><span class="cx"> http://127.0.0.1:8000/try_to_promote - didFinishLoading
</span><span class="cx"> http://127.0.0.1/nope - willSendRequest <NSURLRequest URL http://127.0.0.1/nope, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="cx"> http://127.0.0.1/nope - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://127.0.0.1/nope">
</span><del>-CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https://127.0.0.1/promote
</del><ins>+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https
</ins><span class="cx"> https://127.0.0.1/promote - willSendRequest <NSURLRequest URL https://127.0.0.1/promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="cx"> https://127.0.0.1/promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/promote">
</span><del>-CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https://127.0.0.1/promote
</del><ins>+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https
</ins><span class="cx"> https://127.0.0.1/promote - willSendRequest <NSURLRequest URL https://127.0.0.1/promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="cx"> https://127.0.0.1/promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/promote">
</span><del>-CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https://127.0.0.1/promote
</del><ins>+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https
</ins><span class="cx"> https://127.0.0.1/promote - willSendRequest <NSURLRequest URL https://127.0.0.1/promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="cx"> https://127.0.0.1/promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/promote">
</span><span class="cx"> http://127.0.0.1:443/try_to_promote - willSendRequest <NSURLRequest URL http://127.0.0.1:443/try_to_promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx"> http://127.0.0.1:443/try_to_promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://127.0.0.1:443/try_to_promote">
</span><span class="cx"> http://127.0.0.1:1443/try_to_promote - willSendRequest <NSURLRequest URL http://127.0.0.1:1443/try_to_promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="cx"> http://127.0.0.1:1443/try_to_promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://127.0.0.1:1443/try_to_promote">
</span><del>-CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://promote/ to https://promote/
</del><ins>+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://promote/ to https
</ins><span class="cx"> https://promote/ - willSendRequest <NSURLRequest URL https://promote/, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
</span><span class="cx"> Blocked access to external URL https://promote/
</span><span class="cx"> https://promote/ - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999>
</span></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests that WebSocket sends no cookies when they are blocked.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+WebSocket open
+WebSocket message (no cookies)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesworkerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests that WebSocket sends no cookies when they are blocked.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+worker WebSocket open
+PASS worker WebSocket message (no cookies)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesworkerphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+<?php
+if ( isset($_GET['clear'])) {
+ header("Content-Type: text/plain");
+ setcookie("WK-websocket-test", "0", time()-1);
+ setcookie("WK-websocket-test-httponly", "0", time()-1, "", "", false, true);
+ echo("Cookies are cleared.");
+ return;
+} else {
+ header("Content-Type: text/html");
+ setcookie("WK-websocket-test", "1");
+ setcookie("WK-websocket-test-httponly", "1", time()+3600, "", "", false, true);
+ header("Set-Cookie: WK-websocket-test=1");
+ header("Set-Cookie: WK-websocket-test-httponly=1; HttpOnly");
+}
+?>
+<html>
+<head>
+<script src="../../../../../js-test-resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Tests that WebSocket sends no cookies when they are blocked.</p>
+<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
+<div id="console"></div>
+<script>
+window.jsTestIsAsync = true;
+
+function startsWith(str, prefix) {
+ return str.indexOf(prefix) == 0;
+}
+
+var worker = new Worker("resources/block-cookies-worker.js");
+worker.onmessage = function (event)
+{
+ var message = event.data;
+ debug(message);
+ if (startsWith(message, "PASS") || startsWith(message, "FAIL"))
+                finishJSTest();
+};
+
+</script>
+<script src="../../../../../js-test-resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesworkerphpjson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block-cookies"
+ },
+ "trigger": {
+ "url-filter": "8880"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<?php
+if ( isset($_GET['clear'])) {
+ header("Content-Type: text/plain");
+ setcookie("WK-websocket-test", "0", time()-1);
+ setcookie("WK-websocket-test-httponly", "0", time()-1, "", "", false, true);
+ echo("Cookies are cleared.");
+ return;
+} else {
+ header("Content-Type: text/html");
+ setcookie("WK-websocket-test", "1");
+ setcookie("WK-websocket-test-httponly", "1", time()+3600, "", "", false, true);
+ header("Set-Cookie: WK-websocket-test=1");
+ header("Set-Cookie: WK-websocket-test-httponly=1; HttpOnly");
+}
+?>
+<html>
+<head>
+<script src="../../../../../js-test-resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Tests that WebSocket sends no cookies when they are blocked.</p>
+<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
+<div id="console"></div>
+<script>
+window.jsTestIsAsync = true;
+
+function clearCookies()
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "block-cookies.php?clear=1", false);
+ xhr.send(null);
+}
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/contentextensions/resources/echo-cookie");
+ws.onopen = function() {
+ debug("WebSocket open");
+};
+ws.onmessage = function(evt) {
+ debug("WebSocket message (" + evt.data + ")");
+ clearCookies();
+ finishJSTest();
+};
+
+</script>
+<script src="../../../../../js-test-resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4>Added: svn:executable</h4></div>
<ins>+*
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockcookiesphpjson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-cookies.php.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block-cookies"
+ },
+ "trigger": {
+ "url-filter": "8880"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 13: Content blocker prevented frame displaying http://127.0.0.1:8000/websocket/tests/hybi/contentextensions/block.html from loading a resource from ws://localhost:8880/websocket/tests/hybi/contentextensions/resources/echo
+CONSOLE MESSAGE: line 27: onerror
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockworkerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: Content blocker prevented frame displaying http://127.0.0.1:8000/websocket/tests/hybi/contentextensions/block-worker.html from loading a resource from ws://localhost:8880/websocket/tests/hybi/contentextensions/resources/echo
+CONSOLE MESSAGE: line 21: PASS worker onerror
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockworkerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function endTest() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+function startsWith(str, prefix) {
+ return str.indexOf(prefix) == 0;
+}
+
+var worker = new Worker("resources/block-worker.js");
+worker.onmessage = function (event)
+{
+ var message = event.data;
+ console.log(message);
+ if (startsWith(message, "PASS") || startsWith(message, "FAIL"))
+                endTest();
+};
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockworkerhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block-worker.html.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": "8880"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function endTest() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/contentextensions/resources/echo");
+
+ws.onopen = function() {
+ console.log("onopen");
+ ws.send("sent");
+}
+ws.onmessage = function(message) {
+ console.log("onmessage " + message.data);
+}
+ws.onclose = function() {
+ console.log("onclose");
+ endTest();
+}
+ws.onerror = function(ev) {
+ console.log("onerror");
+ endTest();
+}
+
+setTimeout(function() {
+ console.log("timeout");
+ endTest();
+}, 3000);
+
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsblockhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/block.html.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": "8880"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+CONSOLE MESSAGE: line 18: onopen
+CONSOLE MESSAGE: line 22: onmessage reply sent
+CONSOLE MESSAGE: line 25: onclose
+This should not be hidden.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneworkerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+CONSOLE MESSAGE: line 23: worker onopen
+CONSOLE MESSAGE: line 23: worker onmessage reply sent
+CONSOLE MESSAGE: line 23: PASS worker onclose
+This should not be hidden.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneworkerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+<div id="should_be_hidden">This should be hidden by a css selector from the content extension.</div>
+<div id="should_not_be_hidden">This should not be hidden.</div>
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function endTest() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+function startsWith(str, prefix) {
+ return str.indexOf(prefix) == 0;
+}
+
+var worker = new Worker("resources/display-none-worker.js");
+worker.onmessage = function (event)
+{
+ var message = event.data;
+ console.log(message);
+ if (startsWith(message, "PASS") || startsWith(message, "FAIL"))
+                endTest();
+};
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynoneworkerhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "css-display-none",
+ "selector": "#should_be_hidden"
+ },
+ "trigger": {
+ "url-filter": "8880"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynonehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+<div id="should_be_hidden">This should be hidden by a css selector from the content extension.</div>
+<div id="should_not_be_hidden">This should not be hidden.</div>
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function endTest() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/contentextensions/resources/echo");
+
+ws.onopen = function() {
+ console.log("onopen");
+ ws.send("sent");
+}
+ws.onmessage = function(message) {
+ console.log("onmessage " + message.data);
+}
+ws.onclose = function() {
+ console.log("onclose");
+ endTest();
+}
+ws.onerror = function() {
+ console.log("onerror");
+ endTest();
+}
+
+setTimeout(function() {
+ console.log("timeout");
+ endTest();
+}, 3000);
+
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsdisplaynonehtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/display-none.html.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "css-display-none",
+ "selector": "#should_be_hidden"
+ },
+ "trigger": {
+ "url-filter": "8880"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesblockcookiesworkerjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-cookies-worker.js        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+function clearCookies()
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "block-cookies-worker.php?clear=1", false);
+ xhr.send(null);
+}
+
+var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/contentextensions/resources/echo-cookie");
+ws.onopen = function() {
+ postMessage("worker WebSocket open");
+};
+ws.onmessage = function(evt) {
+ clearCookies();
+ postMessage("PASS worker WebSocket message (" + evt.data + ")");
+};
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesblockworkerjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-worker.js (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-worker.js         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/block-worker.js        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/contentextensions/resources/echo");
+
+ws.onopen = function() {
+ postMessage("FAIL worker onopen");
+}
+ws.onmessage = function(message) {
+ postMessage("FAIL worker onmessage " + message.data);
+}
+ws.onclose = function() {
+ postMessage("FAIL worker onclose");
+}
+ws.onerror = function() {
+ postMessage("PASS worker onerror");
+}
+
+setTimeout(function() {
+ postMessage("FAIL worker timeout");
+}, 3000);
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesdisplaynoneworkerjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/display-none-worker.js (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/display-none-worker.js         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/display-none-worker.js        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+var ws = new WebSocket("ws://localhost:8880/websocket/tests/hybi/contentextensions/resources/echo");
+
+ws.onopen = function() {
+ postMessage("worker onopen");
+ ws.send("sent");
+}
+ws.onmessage = function(message) {
+ postMessage("worker onmessage " + message.data);
+}
+ws.onclose = function() {
+ postMessage("PASS worker onclose");
+}
+ws.onerror = function() {
+ postMessage("FAIL worker onerror");
+}
+
+setTimeout(function() {
+ postMessage("FAIL worker timeout");
+}, 3000);
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesechocookie_wshpy"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo-cookie_wsh.py (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo-cookie_wsh.py         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo-cookie_wsh.py        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+# Copyright (C) 2010 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+from mod_pywebsocket import msgutil
+
+
+def web_socket_do_extra_handshake(request):
+ pass
+
+
+def web_socket_transfer_data(request):
+ try:
+ msgutil.send_message(request, "cookie:" + request.headers_in['Cookie'])
+ except:
+ msgutil.send_message(request, "no cookies")
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesecho_wshpy"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo_wsh.py (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo_wsh.py         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/echo_wsh.py        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+from mod_pywebsocket import msgutil
+
+def web_socket_do_extra_handshake(request):
+ pass
+
+def web_socket_transfer_data(request):
+ for unused in range(1):
+ message = msgutil.receive_message(request)
+ msgutil.send_message(request, "reply " + message)
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsresourcesupgradeworkerjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/upgrade-worker.js (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/upgrade-worker.js         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/resources/upgrade-worker.js        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+var ws = new WebSocket("ws://127.0.0.1/websocket/tests/hybi/simple");
+
+ws.onopen = function() {
+ postMessage("FAIL worker onopen");
+}
+ws.onmessage = function(message) {
+ postMessage("FAIL worker onmessage " + message.data);
+}
+ws.onclose = function() {
+ postMessage("PASS worker onclose url " + ws.url);
+}
+ws.onerror = function() {
+ postMessage("FAIL worker onerror");
+}
+
+setTimeout(function() {
+ postMessage("FAIL worker timeout");
+}, 3000);
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+CONSOLE MESSAGE: line 14: Content blocker promoted URL from ws://127.0.0.1/websocket/tests/hybi/simple to wss
+CONSOLE MESSAGE: WebSocket network error: The operation couldn’t be completed. Connection refused
+CONSOLE MESSAGE: line 24: onclose
+CONSOLE MESSAGE: line 9: new url: wss://127.0.0.1/websocket/tests/hybi/simple
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeworkerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker-expected.txt (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker-expected.txt        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+CONSOLE MESSAGE: Content blocker promoted URL from ws://127.0.0.1/websocket/tests/hybi/simple to wss
+CONSOLE MESSAGE: WebSocket network error: The operation couldn’t be completed. Connection refused
+CONSOLE MESSAGE: line 21: PASS worker onclose url wss://127.0.0.1/websocket/tests/hybi/simple
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeworkerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function endTest() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+function startsWith(str, prefix) {
+ return str.indexOf(prefix) == 0;
+}
+
+var worker = new Worker("resources/upgrade-worker.js");
+worker.onmessage = function (event)
+{
+ var message = event.data;
+ console.log(message);
+ if (startsWith(message, "PASS") || startsWith(message, "FAIL"))
+                endTest();
+};
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradeworkerhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "make-https"
+ },
+ "trigger": {
+ "url-filter": "simple"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function endTest() {
+ console.log("new url: " + ws.url);
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var ws = new WebSocket("ws://127.0.0.1/websocket/tests/hybi/simple");
+
+ws.onopen = function() {
+ console.log("onopen");
+ ws.send("sent");
+}
+ws.onmessage = function(message) {
+ console.log("onmessage " + message.data);
+}
+ws.onclose = function() {
+ console.log("onclose");
+ endTest();
+}
+ws.onerror = function(ev) {
+ console.log("onerror");
+ endTest();
+}
+
+setTimeout(function() {
+ console.log("timeout");
+ endTest();
+}, 3000);
+
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestswebsockettestshybicontentextensionsupgradehtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html.json (0 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/contentextensions/upgrade.html.json        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "make-https"
+ },
+ "trigger": {
+ "url-filter": "simple"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -440,6 +440,7 @@
</span><span class="cx">
</span><span class="cx"> # Content Extensions tests must be enabled explicitly on mac-wk2.
</span><span class="cx"> http/tests/contentextensions [ Pass ]
</span><ins>+http/tests/websocket/tests/hybi/contentextensions [ Pass ]
</ins><span class="cx"> webkit.org/b/146400 http/tests/contentextensions/character-set-basic-support.html [ Pass Failure ]
</span><span class="cx">
</span><span class="cx"> # WebKit1-only failure.
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/ChangeLog        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -1,3 +1,122 @@
</span><ins>+2016-08-04 Alex Christensen <achristensen@webkit.org>
+
+ Content Blocker cannot block WebSocket connections
+ https://bugs.webkit.org/show_bug.cgi?id=160159
+
+ Reviewed by Brady Eidson.
+
+ Tests: http/tests/websocket/tests/hybi/contentextensions/block-cookies-worker.php
+ http/tests/websocket/tests/hybi/contentextensions/block-cookies.php
+ http/tests/websocket/tests/hybi/contentextensions/block-worker.html
+ http/tests/websocket/tests/hybi/contentextensions/block.html
+ http/tests/websocket/tests/hybi/contentextensions/display-none-worker.html
+ http/tests/websocket/tests/hybi/contentextensions/display-none.html
+ http/tests/websocket/tests/hybi/contentextensions/upgrade-worker.html
+ http/tests/websocket/tests/hybi/contentextensions/upgrade.html
+
+ * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
+ (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
+ (WebCore::ThreadableWebSocketChannelClientWrapper::didUpgradeURL):
+ (WebCore::ThreadableWebSocketChannelClientWrapper::suspend):
+ * Modules/websockets/ThreadableWebSocketChannelClientWrapper.h:
+ * Modules/websockets/WebSocket.cpp:
+ (WebCore::WebSocket::didClose):
+ (WebCore::WebSocket::didUpgradeURL):
+ (WebCore::WebSocket::getFramingOverhead):
+ * Modules/websockets/WebSocket.h:
+
+ Added didUpgradeURL to WebSocketChannelClient so the WebSocketChannel can tell the WebSocket
+ that it has upgraded a ws: url to a wss: url.
+
+ * Modules/websockets/WebSocketChannel.cpp:
+ (WebCore::WebSocketChannel::~WebSocketChannel):
+ (WebCore::WebSocketChannel::connect):
+
+ If content extensions are being used, run the URL through the content extension and apply its actions
+ before connecting the WebSocket. This is done in WebSocketChannel instead of WebSocket like the CSP checks
+ because we need access to the Document in order to get access to the main document's URL for if-domain and
+ unless-domain rules, and to apply any display:none css to the Document.
+
+ (WebCore::WebSocketChannel::disconnect):
+ * Modules/websockets/WebSocketChannelClient.h:
+ (WebCore::WebSocketChannelClient::~WebSocketChannelClient):
+ (WebCore::WebSocketChannelClient::WebSocketChannelClient):
+ (WebCore::WebSocketChannelClient::didConnect):
+ (WebCore::WebSocketChannelClient::didReceiveMessage):
+ (WebCore::WebSocketChannelClient::didReceiveBinaryData):
+ (WebCore::WebSocketChannelClient::didReceiveMessageError):
+ (WebCore::WebSocketChannelClient::didUpdateBufferedAmount):
+ (WebCore::WebSocketChannelClient::didStartClosingHandshake):
+ (WebCore::WebSocketChannelClient::didClose):
+
+ Made WebSocketChannelClient purely virtual to avoid accidentally making an implementation that is missing functionality.
+
+ (WebCore::WebSocketChannelClient::didUpgradeURL): Added.
+ * Modules/websockets/WebSocketHandshake.cpp:
+ (WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
+ (WebCore::WebSocketHandshake::WebSocketHandshake):
+ (WebCore::WebSocketHandshake::clientOrigin):
+ (WebCore::WebSocketHandshake::clientLocation):
+ (WebCore::WebSocketHandshake::clientHandshakeMessage):
+
+ Only put cookies on the WebSocket's handshake if we are allowed to use cookies.
+
+ (WebCore::WebSocketHandshake::clientHandshakeRequest):
+
+ A WebSocketHandshake always has a Document* for its ScriptExecutionContext, so I replaced m_context with
+ m_document and removed a suspicious-looking check for is<Document> that turned out to not be suspicious at all.
+
+ (WebCore::WebSocketHandshake::reset):
+ (WebCore::WebSocketHandshake::clearDocument):
+ (WebCore::WebSocketHandshake::readServerHandshake):
+ (WebCore::WebSocketHandshake::clearScriptExecutionContext): Deleted.
+ * Modules/websockets/WebSocketHandshake.h:
+ * Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
+ (WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveMessageError):
+ (WebCore::WorkerThreadableWebSocketChannel::Peer::didUpgradeURL):
+ (WebCore::WorkerThreadableWebSocketChannel::Bridge::Bridge):
+ * Modules/websockets/WorkerThreadableWebSocketChannel.h:
+ * contentextensions/ContentExtensionActions.h:
+
+ Before this change we would pass a ResourceRequest as a parameter to the content extension engine.
+ The ResourceRequest would be used to get the URL, and it would be modified by possibly disabling cookies
+ or making the URL https. Any display:none CSS rules added were put into the Document through the DocumentLoader.
+ The only information it needed to return was whether the load was blocked.
+ To make content extensions work with WebSockets, we need to pass a URL as a parameter instead of a ResourceRequest
+ because there is no ResourceRequest with WebSockets, only a URL. We can still put CSS rules in through the DocumentLoader,
+ but the rest of the actions need to be returned through the return value, which is then processed by the callers.
+ BlockedStatus is now a struct containing a set of actions to apply, and applyBlockedStatusToRequest is a helper function
+ that applies the actions to the ResourceRequests we have at all previously existing call sites of processContentExtensionRulesForLoad.
+
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::globalDisplayNoneStyleSheet):
+ (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
+ (WebCore::ContentExtensions::ContentExtensionsBackend::displayNoneCSSRule):
+ (WebCore::ContentExtensions::applyBlockedStatusToRequest):
+ * contentextensions/ContentExtensionsBackend.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::loadResource):
+
+ Here, we also only had a URL. Before, we were making a ResourceRequest from the URL just for the content extension engine,
+ but now we can just pass the URL.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadResourceSynchronously):
+ * loader/PingLoader.cpp:
+ (WebCore::processContentExtensionRulesForLoad):
+ (WebCore::PingLoader::loadImage):
+ (WebCore::PingLoader::sendPing):
+ (WebCore::PingLoader::sendViolationReport):
+ * loader/ResourceLoader.cpp:
+ (WebCore::ResourceLoader::willSendRequestInternal):
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestResource):
+ * page/UserContentProvider.cpp:
+ (WebCore::contentExtensionsEnabled):
+ (WebCore::UserContentProvider::processContentExtensionRulesForLoad):
+ (WebCore::UserContentProvider::actionsForResourceLoad):
+ * page/UserContentProvider.h:
+
</ins><span class="cx"> 2016-08-04 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> [[Prototype]] property of an interface object for a callback interface must be the Object.prototype object
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsThreadableWebSocketChannelClientWrappercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -229,6 +229,17 @@
</span><span class="cx"> processPendingTasks();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ThreadableWebSocketChannelClientWrapper::didUpgradeURL()
+{
+ m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) {
+ if (m_client)
+ m_client->didUpgradeURL();
+ }));
+
+ if (!m_suspended)
+ processPendingTasks();
+}
+
</ins><span class="cx"> void ThreadableWebSocketChannelClientWrapper::suspend()
</span><span class="cx"> {
</span><span class="cx"> m_suspended = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsThreadableWebSocketChannelClientWrapperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -83,6 +83,7 @@
</span><span class="cx"> void didStartClosingHandshake();
</span><span class="cx"> void didClose(unsigned unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
</span><span class="cx"> void didReceiveMessageError();
</span><ins>+ void didUpgradeURL();
</ins><span class="cx">
</span><span class="cx"> void suspend();
</span><span class="cx"> void resume();
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -635,6 +635,12 @@
</span><span class="cx"> ActiveDOMObject::unsetPendingActivity(this);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebSocket::didUpgradeURL()
+{
+ ASSERT(m_url.protocolIs("ws"));
+ m_url.setProtocol("wss");
+}
+
</ins><span class="cx"> size_t WebSocket::getFramingOverhead(size_t payloadSize)
</span><span class="cx"> {
</span><span class="cx"> static const size_t hybiBaseFramingOverhead = 2; // Every frame has at least two-byte header.
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocket.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -96,13 +96,14 @@
</span><span class="cx"> using RefCounted<WebSocket>::deref;
</span><span class="cx">
</span><span class="cx"> // WebSocketChannelClient functions.
</span><del>- void didConnect() override;
- void didReceiveMessage(const String& message) override;
- void didReceiveBinaryData(Vector<uint8_t>&&) override;
- void didReceiveMessageError() override;
- void didUpdateBufferedAmount(unsigned bufferedAmount) override;
- void didStartClosingHandshake() override;
- void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override;
</del><ins>+ void didConnect() final;
+ void didReceiveMessage(const String& message) final;
+ void didReceiveBinaryData(Vector<uint8_t>&&) final;
+ void didReceiveMessageError() final;
+ void didUpdateBufferedAmount(unsigned bufferedAmount) final;
+ void didStartClosingHandshake() final;
+ void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) final;
+ void didUpgradeURL() final;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> explicit WebSocket(ScriptExecutionContext&);
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketChannelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> #include "SocketProvider.h"
</span><span class="cx"> #include "SocketStreamError.h"
</span><span class="cx"> #include "SocketStreamHandle.h"
</span><ins>+#include "UserContentProvider.h"
</ins><span class="cx"> #include "WebSocketChannelClient.h"
</span><span class="cx"> #include "WebSocketHandshake.h"
</span><span class="cx"> #include <runtime/ArrayBuffer.h>
</span><span class="lines">@@ -83,12 +84,39 @@
</span><span class="cx"> LOG(Network, "WebSocketChannel %p dtor", this);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebSocketChannel::connect(const URL& url, const String& protocol)
</del><ins>+void WebSocketChannel::connect(const URL& requestedURL, const String& protocol)
</ins><span class="cx"> {
</span><span class="cx"> LOG(Network, "WebSocketChannel %p connect()", this);
</span><ins>+
+ URL url = requestedURL;
+ bool allowCookies = true;
+#if ENABLE(CONTENT_EXTENSIONS)
+ if (auto* page = m_document->page()) {
+ if (auto* documentLoader = m_document->loader()) {
+ auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(url, ResourceType::Raw, *documentLoader);
+ if (blockedStatus.blockedLoad) {
+ Ref<WebSocketChannel> protectedThis(*this);
+ callOnMainThread([protectedThis = WTFMove(protectedThis)] {
+ if (protectedThis->m_client)
+ protectedThis->m_client->didReceiveMessageError();
+ });
+ return;
+ }
+ if (blockedStatus.madeHTTPS) {
+ ASSERT(url.protocolIs("ws"));
+ url.setProtocol("wss");
+ if (m_client)
+ m_client->didUpgradeURL();
+ }
+ if (blockedStatus.blockedCookies)
+ allowCookies = false;
+ }
+ }
+#endif
+
</ins><span class="cx"> ASSERT(!m_handle);
</span><span class="cx"> ASSERT(!m_suspended);
</span><del>- m_handshake = std::make_unique<WebSocketHandshake>(url, protocol, m_document);
</del><ins>+ m_handshake = std::make_unique<WebSocketHandshake>(url, protocol, m_document, allowCookies);
</ins><span class="cx"> m_handshake->reset();
</span><span class="cx"> if (m_deflateFramer.canDeflate())
</span><span class="cx"> m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor());
</span><span class="lines">@@ -226,7 +254,7 @@
</span><span class="cx"> if (m_identifier && m_document)
</span><span class="cx"> InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier);
</span><span class="cx"> if (m_handshake)
</span><del>- m_handshake->clearScriptExecutionContext();
</del><ins>+ m_handshake->clearDocument();
</ins><span class="cx"> m_client = nullptr;
</span><span class="cx"> m_document = nullptr;
</span><span class="cx"> if (m_handle)
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketChannelClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -40,17 +40,18 @@
</span><span class="cx"> class WebSocketChannelClient {
</span><span class="cx"> public:
</span><span class="cx"> virtual ~WebSocketChannelClient() { }
</span><del>- virtual void didConnect() { }
- virtual void didReceiveMessage(const String&) { }
- virtual void didReceiveBinaryData(Vector<uint8_t>&&) { }
- virtual void didReceiveMessageError() { }
- virtual void didUpdateBufferedAmount(unsigned /* bufferedAmount */) { }
- virtual void didStartClosingHandshake() { }
</del><ins>+ virtual void didConnect() = 0;
+ virtual void didReceiveMessage(const String&) = 0;
+ virtual void didReceiveBinaryData(Vector<uint8_t>&&) = 0;
+ virtual void didReceiveMessageError() = 0;
+ virtual void didUpdateBufferedAmount(unsigned bufferedAmount) = 0;
+ virtual void didStartClosingHandshake() = 0;
</ins><span class="cx"> enum ClosingHandshakeCompletionStatus {
</span><span class="cx"> ClosingHandshakeIncomplete,
</span><span class="cx"> ClosingHandshakeComplete
</span><span class="cx"> };
</span><del>- virtual void didClose(unsigned /* unhandledBufferedAmount */, ClosingHandshakeCompletionStatus, unsigned short /* code */, const String& /* reason */) { }
</del><ins>+ virtual void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) = 0;
+ virtual void didUpgradeURL() = 0;
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> WebSocketChannelClient() { }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketHandshakecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -121,12 +121,13 @@
</span><span class="cx"> return base64Encode(hash.data(), SHA1::hashSize);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebSocketHandshake::WebSocketHandshake(const URL& url, const String& protocol, ScriptExecutionContext* context)
</del><ins>+WebSocketHandshake::WebSocketHandshake(const URL& url, const String& protocol, Document* document, bool allowCookies)
</ins><span class="cx"> : m_url(url)
</span><span class="cx"> , m_clientProtocol(protocol)
</span><span class="cx"> , m_secure(m_url.protocolIs("wss"))
</span><del>- , m_context(context)
</del><ins>+ , m_document(document)
</ins><span class="cx"> , m_mode(Incomplete)
</span><ins>+ , m_allowCookies(allowCookies)
</ins><span class="cx"> {
</span><span class="cx"> m_secWebSocketKey = generateSecWebSocketKey();
</span><span class="cx"> m_expectedAccept = getExpectedWebSocketAccept(m_secWebSocketKey);
</span><span class="lines">@@ -169,7 +170,7 @@
</span><span class="cx">
</span><span class="cx"> String WebSocketHandshake::clientOrigin() const
</span><span class="cx"> {
</span><del>- return m_context->securityOrigin()->toString();
</del><ins>+ return m_document->securityOrigin()->toString();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String WebSocketHandshake::clientLocation() const
</span><span class="lines">@@ -200,12 +201,10 @@
</span><span class="cx"> fields.append("Sec-WebSocket-Protocol: " + m_clientProtocol);
</span><span class="cx">
</span><span class="cx"> URL url = httpURLForAuthenticationAndCookies();
</span><del>- if (is<Document>(*m_context)) {
- Document& document = downcast<Document>(*m_context);
- String cookie = cookieRequestHeaderFieldValue(&document, url);
</del><ins>+ if (m_allowCookies) {
+ String cookie = cookieRequestHeaderFieldValue(m_document, url);
</ins><span class="cx"> if (!cookie.isEmpty())
</span><span class="cx"> fields.append("Cookie: " + cookie);
</span><del>- // Set "Cookie2: <cookie>" if cookies 2 exists for url?
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Add no-cache headers to avoid compatibility issue.
</span><span class="lines">@@ -222,7 +221,7 @@
</span><span class="cx"> fields.append("Sec-WebSocket-Extensions: " + extensionValue);
</span><span class="cx">
</span><span class="cx"> // Add a User-Agent header.
</span><del>- fields.append("User-Agent: " + m_context->userAgent(m_context->url()));
</del><ins>+ fields.append("User-Agent: " + m_document->userAgent(m_document->url()));
</ins><span class="cx">
</span><span class="cx"> // Fields in the handshake are sent by the client in a random order; the
</span><span class="cx"> // order is not meaningful. Thus, it's ok to send the order we constructed
</span><span class="lines">@@ -251,12 +250,10 @@
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketProtocol, m_clientProtocol);
</span><span class="cx">
</span><span class="cx"> URL url = httpURLForAuthenticationAndCookies();
</span><del>- if (is<Document>(*m_context)) {
- Document& document = downcast<Document>(*m_context);
- String cookie = cookieRequestHeaderFieldValue(&document, url);
</del><ins>+ if (m_allowCookies) {
+ String cookie = cookieRequestHeaderFieldValue(m_document, url);
</ins><span class="cx"> if (!cookie.isEmpty())
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::Cookie, cookie);
</span><del>- // Set "Cookie2: <cookie>" if cookies 2 exists for url?
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::Pragma, "no-cache");
</span><span class="lines">@@ -269,7 +266,7 @@
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::SecWebSocketExtensions, extensionValue);
</span><span class="cx">
</span><span class="cx"> // Add a User-Agent header.
</span><del>- request.setHTTPHeaderField(HTTPHeaderName::UserAgent, m_context->userAgent(m_context->url()));
</del><ins>+ request.setHTTPHeaderField(HTTPHeaderName::UserAgent, m_document->userAgent(m_document->url()));
</ins><span class="cx">
</span><span class="cx"> return request;
</span><span class="cx"> }
</span><span class="lines">@@ -280,9 +277,9 @@
</span><span class="cx"> m_extensionDispatcher.reset();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebSocketHandshake::clearScriptExecutionContext()
</del><ins>+void WebSocketHandshake::clearDocument()
</ins><span class="cx"> {
</span><del>- m_context = nullptr;
</del><ins>+ m_document = nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int WebSocketHandshake::readServerHandshake(const char* header, size_t len)
</span><span class="lines">@@ -350,11 +347,6 @@
</span><span class="cx"> return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::SetCookie);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String WebSocketHandshake::serverSetCookie2() const
-{
- return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::SetCookie2);
-}
-
</del><span class="cx"> String WebSocketHandshake::serverUpgrade() const
</span><span class="cx"> {
</span><span class="cx"> return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::Upgrade);
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWebSocketHandshakeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -41,8 +41,8 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class Document;
</ins><span class="cx"> class ResourceRequest;
</span><del>-class ScriptExecutionContext;
</del><span class="cx">
</span><span class="cx"> class WebSocketHandshake {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(WebSocketHandshake); WTF_MAKE_FAST_ALLOCATED;
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> enum Mode {
</span><span class="cx"> Incomplete, Normal, Failed, Connected
</span><span class="cx"> };
</span><del>- WebSocketHandshake(const URL&, const String& protocol, ScriptExecutionContext*);
</del><ins>+ WebSocketHandshake(const URL&, const String& protocol, Document*, bool allowCookies);
</ins><span class="cx"> ~WebSocketHandshake();
</span><span class="cx">
</span><span class="cx"> const URL& url() const;
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> ResourceRequest clientHandshakeRequest() const;
</span><span class="cx">
</span><span class="cx"> void reset();
</span><del>- void clearScriptExecutionContext();
</del><ins>+ void clearDocument();
</ins><span class="cx">
</span><span class="cx"> int readServerHandshake(const char* header, size_t len);
</span><span class="cx"> Mode mode() const;
</span><span class="lines">@@ -77,7 +77,6 @@
</span><span class="cx">
</span><span class="cx"> String serverWebSocketProtocol() const;
</span><span class="cx"> String serverSetCookie() const;
</span><del>- String serverSetCookie2() const;
</del><span class="cx"> String serverUpgrade() const;
</span><span class="cx"> String serverConnection() const;
</span><span class="cx"> String serverWebSocketAccept() const;
</span><span class="lines">@@ -102,9 +101,10 @@
</span><span class="cx"> URL m_url;
</span><span class="cx"> String m_clientProtocol;
</span><span class="cx"> bool m_secure;
</span><del>- ScriptExecutionContext* m_context;
</del><ins>+ Document* m_document;
</ins><span class="cx">
</span><span class="cx"> Mode m_mode;
</span><ins>+ bool m_allowCookies;
</ins><span class="cx">
</span><span class="cx"> ResourceResponse m_serverHandshakeResponse;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWorkerThreadableWebSocketChannelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -331,6 +331,16 @@
</span><span class="cx"> }, m_taskMode);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WorkerThreadableWebSocketChannel::Peer::didUpgradeURL()
+{
+ ASSERT(isMainThread());
+
+ m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = m_workerClientWrapper.copyRef()](ScriptExecutionContext& context) mutable {
+ ASSERT_UNUSED(context, context.isWorkerGlobalScope());
+ workerClientWrapper->didUpgradeURL();
+ }, m_taskMode);
+}
+
</ins><span class="cx"> WorkerThreadableWebSocketChannel::Bridge::Bridge(Ref<ThreadableWebSocketChannelClientWrapper>&& workerClientWrapper, Ref<WorkerGlobalScope>&& workerGlobalScope, const String& taskMode, Ref<SocketProvider>&& socketProvider)
</span><span class="cx"> : m_workerClientWrapper(WTFMove(workerClientWrapper))
</span><span class="cx"> , m_workerGlobalScope(WTFMove(workerGlobalScope))
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebsocketsWorkerThreadableWebSocketChannelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -93,13 +93,14 @@
</span><span class="cx"> void resume();
</span><span class="cx">
</span><span class="cx"> // WebSocketChannelClient functions.
</span><del>- void didConnect() override;
- void didReceiveMessage(const String& message) override;
- void didReceiveBinaryData(Vector<uint8_t>&&) override;
- void didUpdateBufferedAmount(unsigned bufferedAmount) override;
- void didStartClosingHandshake() override;
- void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override;
- void didReceiveMessageError() override;
</del><ins>+ void didConnect() final;
+ void didReceiveMessage(const String& message) final;
+ void didReceiveBinaryData(Vector<uint8_t>&&) final;
+ void didUpdateBufferedAmount(unsigned bufferedAmount) final;
+ void didStartClosingHandshake() final;
+ void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) final;
+ void didReceiveMessageError() final;
+ void didUpgradeURL() final;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> Ref<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionActionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionActions.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionActions.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionActions.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -23,17 +23,18 @@
</span><span class="cx"> * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef ContentExtensionActions_h
-#define ContentExtensionActions_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><del>-
</del><ins>+
+class ResourceRequest;
+
</ins><span class="cx"> namespace ContentExtensions {
</span><span class="cx">
</span><span class="cx"> typedef uint8_t SerializedActionByte;
</span><del>-
</del><ins>+
</ins><span class="cx"> enum class ActionType : uint8_t {
</span><span class="cx"> BlockLoad,
</span><span class="cx"> BlockCookies,
</span><span class="lines">@@ -44,15 +45,16 @@
</span><span class="cx"> InvalidAction,
</span><span class="cx"> };
</span><span class="cx">
</span><del>-enum class BlockedStatus {
- Blocked,
- NotBlocked,
</del><ins>+struct BlockedStatus {
+ bool blockedLoad { false };
+ bool blockedCookies { false };
+ bool madeHTTPS { false };
</ins><span class="cx"> };
</span><del>-
</del><ins>+
+void applyBlockedStatusToRequest(const BlockedStatus&, ResourceRequest&);
+
</ins><span class="cx"> } // namespace ContentExtensions
</span><del>-
</del><ins>+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(CONTENT_EXTENSIONS)
</span><del>-
-#endif // ContentExtensionActions_h
</del></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -146,10 +146,10 @@
</span><span class="cx"> return contentExtension ? contentExtension->globalDisplayNoneStyleSheet() : nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(ResourceRequest& request, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
</del><ins>+BlockedStatus ContentExtensionsBackend::processContentExtensionRulesForLoad(const URL& url, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
</ins><span class="cx"> {
</span><span class="cx"> if (m_contentExtensions.isEmpty())
</span><del>- return BlockedStatus::NotBlocked;
</del><ins>+ return { };
</ins><span class="cx">
</span><span class="cx"> Document* currentDocument = nullptr;
</span><span class="cx"> URL mainDocumentURL;
</span><span class="lines">@@ -160,15 +160,17 @@
</span><span class="cx"> if (initiatingDocumentLoader.isLoadingMainResource()
</span><span class="cx"> && frame->isMainFrame()
</span><span class="cx"> && resourceType == ResourceType::Document)
</span><del>- mainDocumentURL = request.url();
</del><ins>+ mainDocumentURL = url;
</ins><span class="cx"> else if (Document* mainDocument = frame->mainFrame().document())
</span><span class="cx"> mainDocumentURL = mainDocument->url();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- ResourceLoadInfo resourceLoadInfo = { request.url(), mainDocumentURL, resourceType };
</del><ins>+ ResourceLoadInfo resourceLoadInfo = { url, mainDocumentURL, resourceType };
</ins><span class="cx"> Vector<ContentExtensions::Action> actions = actionsForResourceLoad(resourceLoadInfo);
</span><span class="cx">
</span><span class="cx"> bool willBlockLoad = false;
</span><ins>+ bool willBlockCookies = false;
+ bool willMakeHTTPS = false;
</ins><span class="cx"> for (const auto& action : actions) {
</span><span class="cx"> switch (action.type()) {
</span><span class="cx"> case ContentExtensions::ActionType::BlockLoad:
</span><span class="lines">@@ -175,7 +177,7 @@
</span><span class="cx"> willBlockLoad = true;
</span><span class="cx"> break;
</span><span class="cx"> case ContentExtensions::ActionType::BlockCookies:
</span><del>- request.setAllowCookies(false);
</del><ins>+ willBlockCookies = true;
</ins><span class="cx"> break;
</span><span class="cx"> case ContentExtensions::ActionType::CSSDisplayNoneSelector:
</span><span class="cx"> if (resourceType == ResourceType::Document)
</span><span class="lines">@@ -194,22 +196,9 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case ContentExtensions::ActionType::MakeHTTPS: {
</span><del>- const URL originalURL = request.url();
- if (originalURL.protocolIs("http") && (!originalURL.hasPort() || isDefaultPortForProtocol(originalURL.port(), originalURL.protocol()))) {
- URL newURL = originalURL;
- newURL.setProtocol("https");
- if (originalURL.hasPort())
- newURL.setPort(defaultPortForProtocol("https"));
- request.setURL(newURL);
-
- if (resourceType == ResourceType::Document && initiatingDocumentLoader.isLoadingMainResource()) {
- // This is to make sure the correct 'new' URL shows in the location bar.
- initiatingDocumentLoader.request().setURL(newURL);
- initiatingDocumentLoader.frameLoader()->client().dispatchDidChangeProvisionalURL();
- }
- if (currentDocument)
- currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker promoted URL from ", originalURL.string(), " to ", newURL.string()));
- }
</del><ins>+ if ((url.protocolIs("http") || url.protocolIs("ws"))
+ && (!url.hasPort() || isDefaultPortForProtocol(url.port(), url.protocol())))
+ willMakeHTTPS = true;
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case ContentExtensions::ActionType::IgnorePreviousRules:
</span><span class="lines">@@ -218,12 +207,16 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (willBlockLoad) {
- if (currentDocument)
- currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", request.url().string()));
- return BlockedStatus::Blocked;
</del><ins>+ if (currentDocument) {
+ if (willMakeHTTPS) {
+ ASSERT(url.protocolIs("http") || url.protocolIs("ws"));
+ String newProtocol = url.protocolIs("http") ? ASCIILiteral("https") : ASCIILiteral("wss");
+ currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker promoted URL from ", url.string(), " to ", newProtocol));
+ }
+ if (willBlockLoad)
+ currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker prevented frame displaying ", mainDocumentURL.string(), " from loading a resource from ", url.string()));
</ins><span class="cx"> }
</span><del>- return BlockedStatus::NotBlocked;
</del><ins>+ return { willBlockLoad, willBlockCookies, willMakeHTTPS };
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const String& ContentExtensionsBackend::displayNoneCSSRule()
</span><span class="lines">@@ -232,6 +225,24 @@
</span><span class="cx"> return rule;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void applyBlockedStatusToRequest(const BlockedStatus& status, ResourceRequest& request)
+{
+ if (status.blockedCookies)
+ request.setAllowCookies(false);
+
+ if (status.madeHTTPS) {
+ const URL& originalURL = request.url();
+ ASSERT(originalURL.protocolIs("http"));
+ ASSERT(!originalURL.hasPort() || isDefaultPortForProtocol(originalURL.port(), originalURL.protocol()));
+
+ URL newURL = originalURL;
+ newURL.setProtocol("https");
+ if (originalURL.hasPort())
+ newURL.setPort(defaultPortForProtocol("https"));
+ request.setURL(newURL);
+ }
+}
+
</ins><span class="cx"> } // namespace ContentExtensions
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> WEBCORE_EXPORT Vector<Action> actionsForResourceLoad(const ResourceLoadInfo&) const;
</span><span class="cx"> WEBCORE_EXPORT StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
</span><span class="cx">
</span><del>- BlockedStatus processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
</del><ins>+ BlockedStatus processContentExtensionRulesForLoad(const URL&, ResourceType, DocumentLoader& initiatingDocumentLoader);
</ins><span class="cx">
</span><span class="cx"> static const String& displayNoneCSSRule();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -1355,13 +1355,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>- ResourceRequest request(url);
</del><span class="cx"> DocumentLoader* documentLoader = frame->loader().documentLoader();
</span><span class="cx">
</span><del>- if (documentLoader && page->userContentProvider().processContentExtensionRulesForLoad(request, ResourceType::Media, *documentLoader) == ContentExtensions::BlockedStatus::Blocked) {
- request = { };
- mediaLoadingFailed(MediaPlayer::FormatError);
- return;
</del><ins>+ if (documentLoader) {
+ auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(url, ResourceType::Media, *documentLoader);
+ if (blockedStatus.blockedLoad) {
+ mediaLoadingFailed(MediaPlayer::FormatError);
+ return;
+ }
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -2745,11 +2745,15 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> if (error.isNull()) {
</span><span class="cx"> if (auto* page = m_frame.page()) {
</span><del>- if (m_documentLoader && page->userContentProvider().processContentExtensionRulesForLoad(newRequest, ResourceType::Raw, *m_documentLoader) == ContentExtensions::BlockedStatus::Blocked) {
- newRequest = { };
- error = ResourceError(errorDomainWebKitInternal, 0, initialRequest.url(), emptyString());
- response = { };
- data = nullptr;
</del><ins>+ if (m_documentLoader) {
+ auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(newRequest.url(), ResourceType::Raw, *m_documentLoader);
+ applyBlockedStatusToRequest(blockedStatus, newRequest);
+ if (blockedStatus.blockedLoad) {
+ newRequest = { };
+ error = ResourceError(errorDomainWebKitInternal, 0, initialRequest.url(), emptyString());
+ response = { };
+ data = nullptr;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderPingLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/PingLoader.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/PingLoader.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/loader/PingLoader.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -58,13 +58,13 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-static ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(const Frame& frame, ResourceRequest& request, ResourceType resourceType)
</del><ins>+static ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(const Frame& frame, const URL& url, ResourceType resourceType)
</ins><span class="cx"> {
</span><span class="cx"> if (DocumentLoader* documentLoader = frame.loader().documentLoader()) {
</span><span class="cx"> if (Page* page = frame.page())
</span><del>- return page->userContentProvider().processContentExtensionRulesForLoad(request, resourceType, *documentLoader);
</del><ins>+ return page->userContentProvider().processContentExtensionRulesForLoad(url, resourceType, *documentLoader);
</ins><span class="cx"> }
</span><del>- return ContentExtensions::BlockedStatus::NotBlocked;
</del><ins>+ return { };
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -78,7 +78,9 @@
</span><span class="cx"> ResourceRequest request(url);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>- if (processContentExtensionRulesForLoad(frame, request, ResourceType::Image) == ContentExtensions::BlockedStatus::Blocked)
</del><ins>+ auto blockedStatus = processContentExtensionRulesForLoad(frame, url, ResourceType::Image);
+ applyBlockedStatusToRequest(blockedStatus, request);
+ if (blockedStatus.blockedLoad)
</ins><span class="cx"> return;
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -103,7 +105,9 @@
</span><span class="cx"> ResourceRequest request(pingURL);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>- if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw) == ContentExtensions::BlockedStatus::Blocked)
</del><ins>+ auto blockedStatus = processContentExtensionRulesForLoad(frame, pingURL, ResourceType::Raw);
+ applyBlockedStatusToRequest(blockedStatus, request);
+ if (blockedStatus.blockedLoad)
</ins><span class="cx"> return;
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -136,7 +140,9 @@
</span><span class="cx"> ResourceRequest request(reportURL);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>- if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw) == ContentExtensions::BlockedStatus::Blocked)
</del><ins>+ auto blockedStatus = processContentExtensionRulesForLoad(frame, reportURL, ResourceType::Raw);
+ applyBlockedStatusToRequest(blockedStatus, request);
+ if (blockedStatus.blockedLoad)
</ins><span class="cx"> return;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -336,7 +336,9 @@
</span><span class="cx"> if (frameLoader()) {
</span><span class="cx"> Page* page = frameLoader()->frame().page();
</span><span class="cx"> if (page && m_documentLoader) {
</span><del>- if (page->userContentProvider().processContentExtensionRulesForLoad(request, m_resourceType, *m_documentLoader) == ContentExtensions::BlockedStatus::Blocked) {
</del><ins>+ auto blockedStatus = page->userContentProvider().processContentExtensionRulesForLoad(request.url(), m_resourceType, *m_documentLoader);
+ applyBlockedStatusToRequest(blockedStatus, request);
+ if (blockedStatus.blockedLoad) {
</ins><span class="cx"> request = { };
</span><span class="cx"> didFail(blockedByContentBlockerError());
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -571,7 +571,10 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> if (frame() && frame()->mainFrame().page() && m_documentLoader) {
</span><del>- if (frame()->mainFrame().page()->userContentProvider().processContentExtensionRulesForLoad(request.mutableResourceRequest(), toResourceType(type), *m_documentLoader) == ContentExtensions::BlockedStatus::Blocked) {
</del><ins>+ auto& resourceRequest = request.mutableResourceRequest();
+ auto blockedStatus = frame()->mainFrame().page()->userContentProvider().processContentExtensionRulesForLoad(resourceRequest.url(), toResourceType(type), *m_documentLoader);
+ applyBlockedStatusToRequest(blockedStatus, resourceRequest);
+ if (blockedStatus.blockedLoad) {
</ins><span class="cx"> if (type == CachedResource::Type::MainResource) {
</span><span class="cx"> auto resource = createResource(type, request.mutableResourceRequest(), request.charset(), sessionID());
</span><span class="cx"> ASSERT(resource);
</span><span class="lines">@@ -581,6 +584,12 @@
</span><span class="cx"> }
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><ins>+ if (blockedStatus.madeHTTPS
+ && type == CachedResource::Type::MainResource
+ && m_documentLoader->isLoadingMainResource()) {
+ // This is to make sure the correct 'new' URL shows in the location bar.
+ m_documentLoader->frameLoader()->client().dispatchDidChangeProvisionalURL();
+ }
</ins><span class="cx"> url = request.resourceRequest().url(); // The content extension could have changed it from http to https.
</span><span class="cx"> url = MemoryCache::removeFragmentIdentifierIfNeeded(url); // Might need to remove fragment identifier again.
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentProvider.cpp (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentProvider.cpp        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/page/UserContentProvider.cpp        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -100,12 +100,12 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-ContentExtensions::BlockedStatus UserContentProvider::processContentExtensionRulesForLoad(ResourceRequest& request, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
</del><ins>+ContentExtensions::BlockedStatus UserContentProvider::processContentExtensionRulesForLoad(const URL& url, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
</ins><span class="cx"> {
</span><span class="cx"> if (!contentExtensionsEnabled(initiatingDocumentLoader))
</span><del>- return ContentExtensions::BlockedStatus::NotBlocked;
</del><ins>+ return { };
</ins><span class="cx">
</span><del>- return userContentExtensionBackend().processContentExtensionRulesForLoad(request, resourceType, initiatingDocumentLoader);
</del><ins>+ return userContentExtensionBackend().processContentExtensionRulesForLoad(url, resourceType, initiatingDocumentLoader);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Vector<ContentExtensions::Action> UserContentProvider::actionsForResourceLoad(const ResourceLoadInfo& resourceLoadInfo, DocumentLoader& initiatingDocumentLoader)
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentProvider.h (204126 => 204127)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentProvider.h        2016-08-04 18:03:16 UTC (rev 204126)
+++ trunk/Source/WebCore/page/UserContentProvider.h        2016-08-04 18:07:45 UTC (rev 204127)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> // FIXME: These don't really belong here. They should probably bundled up in the ContentExtensionsBackend
</span><span class="cx"> // which should always exist.
</span><del>- ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
</del><ins>+ ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(const URL&, ResourceType, DocumentLoader& initiatingDocumentLoader);
</ins><span class="cx"> Vector<ContentExtensions::Action> actionsForResourceLoad(const ResourceLoadInfo&, DocumentLoader& initiatingDocumentLoader);
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>