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 f09d2ece98f445c40de0f3ebdabb3a5295bc29b7..09ed96cd82a2b674b99323ad7425bc3ec8518082 100644 |
| --- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| +++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| @@ -80,7 +80,14 @@ namespace blink { |
| namespace { |
| -bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, FetchRequest::DeferOption defer, const Document& document) |
| +void emitWarningForDocWriteScripts(const String& url, Document& document) |
| +{ |
| + String message = "A Parser-blocking, cross-origin script, " + url + ", is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity."; |
| + document.addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); |
| + WTFLogAlways("%s", message.utf8().data()); |
| +} |
| + |
| +bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, FetchRequest::DeferOption defer, Document& document) |
| { |
| // Only scripts inserted via document.write are candidates for having their |
| // fetch disallowed. |
| @@ -115,6 +122,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); |
|
jkarlin
2016/06/23 11:20:41
no need to have two emitWarning calls. Can just ha
shivanisha
2016/06/23 13:56:04
done.
|
| return false; |
| } |
| @@ -123,6 +131,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); |