Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1474)

Unified Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 585873002: Show a warning when using sync xhr. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated patch with reset -expected.txt files. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/core/dom/ExecutionContext.h ('K') | « Source/core/dom/ExecutionContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xml/XMLHttpRequest.cpp
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp
index 69986e041d2e82d180eab8f692b98c05f61ad237..ae0f34197145e87d80c08b2e41528329b4143652 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -590,6 +590,15 @@ void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn
exceptionState.throwDOMException(InvalidAccessError, "Synchronous requests must not set a timeout.");
return;
}
+
+ // Here we just warn that firing sync XHR's may affect responsiveness.
+ // Eventually sync xhr will be deprecated and an "InvalidAccessError" exception thrown.
+ // Refer : https://xhr.spec.whatwg.org/#sync-warning
+ if (!executionContext()->inBeforeUnloadEvent() && !document()->didWarnAboutSyncXHROnce()) {
Mike West 2014/10/01 12:00:44 You can avoid the "didWarnAbout..." flag by using
Mayur Kankanwadi 2014/10/06 12:48:16 Done.
+ document()->setWarnedAboutSyncXHROnce();
+ executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel,
+ "Avoid synchronous requests as it hampers user experience due to unresponsiveness of the web page. Refer https://xhr.spec.whatwg.org/#sync-warning."));
+ }
}
m_method = uppercaseKnownHTTPMethod(method);
« Source/core/dom/ExecutionContext.h ('K') | « Source/core/dom/ExecutionContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698