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

Unified Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2617313002: Add deprecation message for top navigations from sandbox w/ 'allow-top-navigation' but no gesture (Closed)
Patch Set: Add the deprecation message to fix the broken tests in LayoutTests/fast/frames/. Created 3 years, 11 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
Index: third_party/WebKit/Source/core/frame/LocalFrame.cpp
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
index 9f754700b681b8db9480cfba98761e51c2171fef..6f1cd6a70bfa466295117abd93275ada2f6361ed 100644
--- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp
+++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
@@ -466,26 +466,35 @@ SecurityContext* LocalFrame::securityContext() const {
return document();
}
-void LocalFrame::printNavigationErrorMessage(const Frame& targetFrame,
- const char* reason) {
+String LocalFrame::getTargetFrameDescription(const Frame& targetFrame) const {
// URLs aren't available for RemoteFrames, so the error message uses their
// origin instead.
- String targetFrameDescription =
- targetFrame.isLocalFrame()
- ? "with URL '" +
- toLocalFrame(targetFrame).document()->url().getString() + "'"
- : "with origin '" +
- targetFrame.securityContext()->getSecurityOrigin()->toString() +
- "'";
+ return targetFrame.isLocalFrame()
+ ? "with URL '" +
+ toLocalFrame(targetFrame).document()->url().getString() + "'"
+ : "with origin '" +
+ targetFrame.securityContext()
+ ->getSecurityOrigin()
+ ->toString() +
+ "'";
+}
+
+void LocalFrame::printNavigationErrorMessage(const Frame& targetFrame,
+ const char* reason) {
String message =
"Unsafe JavaScript attempt to initiate navigation for frame " +
- targetFrameDescription + " from frame with URL '" +
+ getTargetFrameDescription(targetFrame) + " from frame with URL '" +
document()->url().getString() + "'. " + reason + "\n";
domWindow()->printErrorMessage(message);
}
-void LocalFrame::printNavigationWarning(const String& message) {
+void LocalFrame::printNavigationWarning(const Frame& targetFrame,
+ const char* reason) {
+ String message = "Frame with URL '" + document()->url().getString() +
+ "' attempted to navigate its top-level window " +
+ getTargetFrameDescription(targetFrame) + ". " + reason +
+ "\n";
m_console->addMessage(
ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.h ('k') | third_party/WebKit/Source/core/frame/RemoteFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698