Diff
Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (191098 => 191099)
--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog 2015-10-15 07:28:34 UTC (rev 191098)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog 2015-10-15 07:32:10 UTC (rev 191099)
@@ -1,3 +1,18 @@
+2015-10-15 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r191077. rdar://problem/22993325
+
+ 2015-10-14 Alex Christensen <achristen...@webkit.org>
+
+ [Content Extensions] Make blocked async XHR call onerror
+ https://bugs.webkit.org/show_bug.cgi?id=146706
+
+ Reviewed by Brady Eidson.
+
+ * http/tests/contentextensions/async-xhr-onerror-expected.txt: Added.
+ * http/tests/contentextensions/async-xhr-onerror.html: Added.
+ * http/tests/contentextensions/async-xhr-onerror.html.json: Added.
+
2015-10-14 Matthew Hanson <matthew_han...@apple.com>
Merge r190570. rdar://problem/23075838
Added: branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt (0 => 191099)
--- branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt 2015-10-15 07:32:10 UTC (rev 191099)
@@ -0,0 +1,11 @@
+CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
+CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
+Asynchronous onreadystatechange status: 0, readyState:1, responseText:
+Finished runTest. Waiting for callbacks
+Asynchronous onreadystatechange status: 0, readyState:1, responseText:
+Finished runTest. Waiting for callbacks
+Asynchronous onreadystatechange status: 0, readyState:4, responseText:
+onerror was called.
+Asynchronous onreadystatechange status: 0, readyState:4, responseText:
+onerror was called.
+
Added: branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror.html (0 => 191099)
--- branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror.html (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror.html 2015-10-15 07:32:10 UTC (rev 191099)
@@ -0,0 +1,46 @@
+<head>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+function log(text) {
+ document.body.appendChild(document.createTextNode(text));
+ document.body.appendChild(document.createElement("br"));
+}
+
+function runTest(shouldAbort) {
+ var xhr = new XMLHttpRequest();
+ xhr._onreadystatechange_ = function() {
+ log("Asynchronous onreadystatechange status: " + xhr.status + ", readyState:" + xhr.readyState + ", responseText: " + xhr.responseText);
+ }
+ xhr._ontimeout_ = function () {
+ log("timeout - this should not be called.");
+ };
+ xhr._onerror_ = function () {
+ log("onerror was called.");
+ if (shouldAbort) // The second time this is called.
+ testRunner.notifyDone();
+ };
+
+ xhr.open("GET", "resources/url-blocking-test.js", true);
+ xhr.timeout = 1; // 1 ms should be too late if it is blocked.
+ try {
+ xhr.send();
+ } catch (error) {
+ log("Asynchronous error: " + error);
+ }
+ if (shouldAbort)
+ xhr.abort(); // This should not crash, obviously.
+ log("Finished runTest. Waiting for callbacks");
+}
+
+function runTests() {
+ runTest(false);
+ runTest(true);
+}
+</script>
+</head>
+<body _onload_="runTests()">
+</body>
Added: branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror.html.json (0 => 191099)
--- branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror.html.json (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/http/tests/contentextensions/async-xhr-onerror.html.json 2015-10-15 07:32:10 UTC (rev 191099)
@@ -0,0 +1,10 @@
+[
+ {
+ "action": {
+ "type": "block"
+ },
+ "trigger": {
+ "url-filter": "url-blocking-test"
+ }
+ }
+]
Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (191098 => 191099)
--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog 2015-10-15 07:28:34 UTC (rev 191098)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog 2015-10-15 07:32:10 UTC (rev 191099)
@@ -1,3 +1,27 @@
+2015-10-15 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r191077. rdar://problem/22993325
+
+ 2015-10-14 Alex Christensen <achristen...@webkit.org>
+
+ [Content Extensions] Make blocked async XHR call onerror
+ https://bugs.webkit.org/show_bug.cgi?id=146706
+
+ Reviewed by Brady Eidson.
+
+ Test: http/tests/contentextensions/async-xhr-onerror.html
+
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::XMLHttpRequest):
+ (WebCore::XMLHttpRequest::createRequest):
+ (WebCore::XMLHttpRequest::networkError):
+ (WebCore::XMLHttpRequest::networkErrorTimerFired):
+ (WebCore::XMLHttpRequest::abortError):
+ * xml/XMLHttpRequest.h:
+ Make a timer that calls networkError in 0 time if a content blocker blocks the asynchronous load.
+ It is necessary to call setPendingActivity and dropProtection (which calls unsetPendingActivity)
+ to keep a reference to the XMLHttpRequest alive.
+
2015-10-14 Matthew Hanson <matthew_han...@apple.com>
Merge r191008. rdar://problem/23110743
Modified: branches/safari-601.1.46-branch/Source/WebCore/xml/XMLHttpRequest.cpp (191098 => 191099)
--- branches/safari-601.1.46-branch/Source/WebCore/xml/XMLHttpRequest.cpp 2015-10-15 07:28:34 UTC (rev 191098)
+++ branches/safari-601.1.46-branch/Source/WebCore/xml/XMLHttpRequest.cpp 2015-10-15 07:32:10 UTC (rev 191099)
@@ -138,6 +138,7 @@
, m_responseCacheIsValid(false)
, m_resumeTimer(*this, &XMLHttpRequest::resumeTimerFired)
, m_dispatchErrorOnResuming(false)
+ , m_networkErrorTimer(*this, &XMLHttpRequest::networkErrorTimerFired)
{
#ifndef NDEBUG
xmlHttpRequestCounter.increment();
@@ -778,17 +779,17 @@
if (m_upload)
request.setReportUploadProgress(true);
- // ThreadableLoader::create can return null here, for example if we're no longer attached to a page.
+ // ThreadableLoader::create can return null here, for example if we're no longer attached to a page or if a content blocker blocks the load.
// This is true while running onunload handlers.
// FIXME: Maybe we need to be able to send XMLHttpRequests from onunload, <http://bugs.webkit.org/show_bug.cgi?id=10904>.
- // FIXME: Maybe create() can return null for other reasons too?
m_loader = ThreadableLoader::create(scriptExecutionContext(), this, request, options);
- if (m_loader) {
- // Neither this object nor the _javascript_ wrapper should be deleted while
- // a request is in progress because we need to keep the listeners alive,
- // and they are referenced by the _javascript_ wrapper.
- setPendingActivity(this);
- }
+
+ // Neither this object nor the _javascript_ wrapper should be deleted while
+ // a request is in progress because we need to keep the listeners alive,
+ // and they are referenced by the _javascript_ wrapper.
+ setPendingActivity(this);
+ if (!m_loader)
+ m_networkErrorTimer.startOneShot(0);
} else {
InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContext());
ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), request, *this, options);
@@ -895,6 +896,12 @@
internalAbort();
}
+void XMLHttpRequest::networkErrorTimerFired()
+{
+ networkError();
+ dropProtection();
+}
+
void XMLHttpRequest::abortError()
{
genericError();
Modified: branches/safari-601.1.46-branch/Source/WebCore/xml/XMLHttpRequest.h (191098 => 191099)
--- branches/safari-601.1.46-branch/Source/WebCore/xml/XMLHttpRequest.h 2015-10-15 07:28:34 UTC (rev 191098)
+++ branches/safari-601.1.46-branch/Source/WebCore/xml/XMLHttpRequest.h 2015-10-15 07:32:10 UTC (rev 191099)
@@ -259,6 +259,9 @@
Timer m_resumeTimer;
bool m_dispatchErrorOnResuming;
+
+ Timer m_networkErrorTimer;
+ void networkErrorTimerFired();
};
} // namespace WebCore