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

Side by Side Diff: third_party/WebKit/Source/core/frame/History.cpp

Issue 2206843003: Disable navigations in the unload handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: testharness.js Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (!m_frame || !m_frame->loader().client()) 169 if (!m_frame || !m_frame->loader().client())
170 return; 170 return;
171 171
172 ASSERT(isMainThread()); 172 ASSERT(isMainThread());
173 Document* activeDocument = toDocument(context); 173 Document* activeDocument = toDocument(context);
174 if (!activeDocument) 174 if (!activeDocument)
175 return; 175 return;
176 176
177 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*m_fra me)) 177 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*m_fra me))
178 return; 178 return;
179 if (!NavigationDisablerForBeforeUnload::isNavigationAllowed()) 179 if (!NavigationDisablerForUnload::isNavigationAllowed())
180 return; 180 return;
181 181
182 // We intentionally call reload() for the current frame if delta is zero. 182 // We intentionally call reload() for the current frame if delta is zero.
183 // Otherwise, navigation happens on the root frame. 183 // Otherwise, navigation happens on the root frame.
184 // This behavior is designed in the following spec. 184 // This behavior is designed in the following spec.
185 // https://html.spec.whatwg.org/multipage/browsers.html#dom-history-go 185 // https://html.spec.whatwg.org/multipage/browsers.html#dom-history-go
186 if (delta) 186 if (delta)
187 m_frame->loader().client()->navigateBackForward(delta); 187 m_frame->loader().client()->navigateBackForward(delta);
188 else 188 else
189 m_frame->reload(FrameLoadTypeReload, ClientRedirectPolicy::ClientRedirec t); 189 m_frame->reload(FrameLoadTypeReload, ClientRedirectPolicy::ClientRedirec t);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (!canChangeToUrl(fullURL, m_frame->document()->getSecurityOrigin(), m_fra me->document()->url())) { 234 if (!canChangeToUrl(fullURL, m_frame->document()->getSecurityOrigin(), m_fra me->document()->url())) {
235 // We can safely expose the URL to JavaScript, as a) no redirection take s place: JavaScript already had this URL, b) JavaScript can only access a same-o rigin History object. 235 // We can safely expose the URL to JavaScript, as a) no redirection take s place: JavaScript already had this URL, b) JavaScript can only access a same-o rigin History object.
236 exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f rame->document()->getSecurityOrigin()->toString() + "' and URL '" + m_frame->doc ument()->url().elidedString() + "'."); 236 exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f rame->document()->getSecurityOrigin()->toString() + "' and URL '" + m_frame->doc ument()->url().elidedString() + "'.");
237 return; 237 return;
238 } 238 }
239 239
240 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig ationHistoryApi, data, restorationType, type, m_frame->document()); 240 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig ationHistoryApi, data, restorationType, type, m_frame->document());
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/Deprecation.cpp ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698