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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 1883873002: Do not block document.written scripts in page reloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test modifications to include the blink setting for slow connections Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch Request::DeferOption defer, const Document& document) 80 bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch Request::DeferOption defer, const Document& document)
81 { 81 {
82 // Only scripts inserted via document.write are candidates for having their 82 // Only scripts inserted via document.write are candidates for having their
83 // fetch disallowed. 83 // fetch disallowed.
84 if (!document.isInDocumentWrite()) 84 if (!document.isInDocumentWrite())
85 return false; 85 return false;
86 86
87 if (!document.settings()) 87 if (!document.settings())
88 return false; 88 return false;
89 89
90 if (document.frame())
shivanisha 2016/04/13 16:52:16 Changing this to if (!document.frame())
91 return false;
92
93 // Do not block scripts if it is a page reload. This is to enable pages to
94 // recover if blocking of a script is leading to a page break and the user
95 // reloads the page.
96 const FrameLoadType loadType = document.frame()->loader().loadType();
97 const bool isReload = (loadType == FrameLoadTypeReload || loadType == FrameL oadTypeReloadBypassingCache);
98 if (isReload)
99 return false;
100
shivanisha 2016/04/13 15:56:58 There is also a FrameLoadType value: FrameLoadType
90 const bool isSlowConnection = networkStateNotifier().connectionType() == Web ConnectionTypeCellular2G; 101 const bool isSlowConnection = networkStateNotifier().connectionType() == Web ConnectionTypeCellular2G;
91 const bool disallowFetch = document.settings()->disallowFetchForDocWrittenSc riptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInM ainFrameOnSlowConnections() && isSlowConnection); 102 const bool disallowFetch = document.settings()->disallowFetchForDocWrittenSc riptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInM ainFrameOnSlowConnections() && isSlowConnection);
92 if (!disallowFetch) 103 if (!disallowFetch)
93 return false; 104 return false;
94 105
95 // Only block synchronously loaded (parser blocking) scripts. 106 // Only block synchronously loaded (parser blocking) scripts.
96 if (defer != FetchRequest::NoDefer) 107 if (defer != FetchRequest::NoDefer)
97 return false; 108 return false;
98 109
99 // Avoid blocking same origin scripts, as they may be used to render main 110 // Avoid blocking same origin scripts, as they may be used to render main
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 804 }
794 805
795 DEFINE_TRACE(FrameFetchContext) 806 DEFINE_TRACE(FrameFetchContext)
796 { 807 {
797 visitor->trace(m_document); 808 visitor->trace(m_document);
798 visitor->trace(m_documentLoader); 809 visitor->trace(m_documentLoader);
799 FetchContext::trace(visitor); 810 FetchContext::trace(visitor);
800 } 811 }
801 812
802 } // namespace blink 813 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-reload-no-cache-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698