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

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

Issue 1085973003: Make error messages for cross-domain access OOPIF-friendly. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase (pull in CL to print errors on calling window) Created 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/frame/LocalFrame.cpp
diff --git a/Source/core/frame/LocalFrame.cpp b/Source/core/frame/LocalFrame.cpp
index 4a6ff2a117449e686e64a17e02d867d38d6c9e5d..6419cb3151e6dd2ddee67bb153e19988d3a7427d 100644
--- a/Source/core/frame/LocalFrame.cpp
+++ b/Source/core/frame/LocalFrame.cpp
@@ -287,11 +287,10 @@ SecurityContext* LocalFrame::securityContext() const
void LocalFrame::printNavigationErrorMessage(const Frame& targetFrame, const char* reason)
{
- if (!targetFrame.isLocalFrame())
- return;
-
- const LocalFrame& targetLocalFrame = toLocalFrameTemporary(targetFrame);
- String message = "Unsafe JavaScript attempt to initiate navigation for frame with URL '" + targetLocalFrame.document()->url().string() + "' from frame with URL '" + document()->url().string() + "'. " + reason + "\n";
+ // URLs aren't available for RemoteFrames, so the error message uses their
+ // origin instead.
+ String targetFrameDescription = targetFrame.isLocalFrame() ? "with URL '" + toLocalFrame(targetFrame).document()->url().string() + "'" : "with origin '" + targetFrame.securityContext()->securityOrigin()->toString() + "'";
+ String message = "Unsafe JavaScript attempt to initiate navigation for frame " + targetFrameDescription + " from frame with URL '" + document()->url().string() + "'. " + reason + "\n";
localDOMWindow()->printErrorMessage(message);
}

Powered by Google App Engine
This is Rietveld 408576698