Chromium Code Reviews| Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| index c08ee5f31a0503f3eaff2cf213ad4023c961e87e..944bb610135809a4bbcbe7a32d8d415df9ef0907 100644 |
| --- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| +++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| @@ -78,6 +78,13 @@ namespace blink { |
| namespace { |
| +void emitWarningForDocWriteScripts(const String& url, const Document& document) |
| +{ |
| + String message = "A Parser-blocking, cross-origin script " + url + " is invoked via document.write. This may get blocked by the browser in slow connections. It is recommended to invoke this script asynchronously."; |
|
jkarlin
2016/06/10 18:38:36
There should also be a link to a help page explain
jkarlin
2016/06/10 18:38:36
Commas needed around the url.
s/may get blocked/m
shivanisha
2016/06/20 14:28:06
Created https://bugs.chromium.org/p/chromium/issue
|
| + const_cast <Document &>(document).addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
|
Nate Chapin
2016/06/10 23:34:32
Nit: Pass the Document non-const instead of const_
shivanisha
2016/06/20 14:28:06
done.
|
| + WTFLogAlways("%s", message.utf8().data()); |
| +} |
| + |
| bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, FetchRequest::DeferOption defer, const Document& document) |
| { |
| // Only scripts inserted via document.write are candidates for having their |
| @@ -113,6 +120,7 @@ bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch |
| // Recording this metric since an increase in number of reloads for pages |
| // where a script was blocked could be indicative of a page break. |
| document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoadingBehaviorDocumentWriteBlockReload); |
| + emitWarningForDocWriteScripts(request.url().getString(), document); |
| return false; |
| } |
| @@ -121,6 +129,8 @@ bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch |
| // the flag will be conveyed to the browser process only once. |
| document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoadingBehaviorDocumentWriteBlock); |
| + emitWarningForDocWriteScripts(request.url().getString(), document); |
| + |
| const bool isSlowConnection = networkStateNotifier().connectionType() == WebConnectionTypeCellular2G; |
| const bool disallowFetch = document.settings()->disallowFetchForDocWrittenScriptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections() && isSlowConnection); |