| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 7921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7932 // Create another window with a cross-origin page, and point its opener to | 7932 // Create another window with a cross-origin page, and point its opener to |
| 7933 // first window. | 7933 // first window. |
| 7934 FrameTestHelpers::WebViewHelper popupWebViewHelper; | 7934 FrameTestHelpers::WebViewHelper popupWebViewHelper; |
| 7935 TestConsoleMessageWebFrameClient popupWebFrameClient; | 7935 TestConsoleMessageWebFrameClient popupWebFrameClient; |
| 7936 WebView* popupView = popupWebViewHelper.initializeAndLoad(m_chromeURL + "hel
lo_world.html", true, &popupWebFrameClient); | 7936 WebView* popupView = popupWebViewHelper.initializeAndLoad(m_chromeURL + "hel
lo_world.html", true, &popupWebFrameClient); |
| 7937 popupView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | 7937 popupView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); |
| 7938 | 7938 |
| 7939 // Attempt a blocked navigation of an opener's subframe, and ensure that | 7939 // Attempt a blocked navigation of an opener's subframe, and ensure that |
| 7940 // the error shows up on the popup (calling) window's console, rather than | 7940 // the error shows up on the popup (calling) window's console, rather than |
| 7941 // the target window. | 7941 // the target window. |
| 7942 popupView->mainFrame()->executeScript(WebScriptSource("opener.frames[1].loca
tion.href='data:text/html,foo'")); | 7942 popupView->mainFrame()->executeScript(WebScriptSource("try { opener.frames[1
].location.href='data:text/html,foo'; } catch (e) {}")); |
| 7943 EXPECT_TRUE(webFrameClient.messages.isEmpty()); | 7943 EXPECT_TRUE(webFrameClient.messages.isEmpty()); |
| 7944 ASSERT_EQ(1u, popupWebFrameClient.messages.size()); | 7944 ASSERT_EQ(1u, popupWebFrameClient.messages.size()); |
| 7945 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[0].text.utf8()
.find("Unsafe JavaScript attempt to initiate navigation")); | 7945 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[0].text.utf8()
.find("Unsafe JavaScript attempt to initiate navigation")); |
| 7946 | 7946 |
| 7947 // Try setting a cross-origin iframe element's source to a javascript: URL, | 7947 // Try setting a cross-origin iframe element's source to a javascript: URL, |
| 7948 // and check that this error is also printed on the calling window. | 7948 // and check that this error is also printed on the calling window. |
| 7949 popupView->mainFrame()->executeScript(WebScriptSource("opener.document.query
SelectorAll('iframe')[1].src='javascript:alert()'")); | 7949 popupView->mainFrame()->executeScript(WebScriptSource("opener.document.query
SelectorAll('iframe')[1].src='javascript:alert()'")); |
| 7950 EXPECT_TRUE(webFrameClient.messages.isEmpty()); | 7950 EXPECT_TRUE(webFrameClient.messages.isEmpty()); |
| 7951 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); | 7951 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); |
| 7952 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); | 7952 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8985 FrameTestHelpers::WebViewHelper helper; | 8985 FrameTestHelpers::WebViewHelper helper; |
| 8986 helper.initializeAndLoad(url, true); | 8986 helper.initializeAndLoad(url, true); |
| 8987 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); | 8987 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); |
| 8988 | 8988 |
| 8989 Document* document = toLocalFrame(helper.webView()->page()->mainFrame())->do
cument(); | 8989 Document* document = toLocalFrame(helper.webView()->page()->mainFrame())->do
cument(); |
| 8990 EXPECT_TRUE(document->isImageDocument()); | 8990 EXPECT_TRUE(document->isImageDocument()); |
| 8991 EXPECT_EQ(Resource::DecodeError, toImageDocument(document)->cachedImage()->g
etStatus()); | 8991 EXPECT_EQ(Resource::DecodeError, toImageDocument(document)->cachedImage()->g
etStatus()); |
| 8992 } | 8992 } |
| 8993 | 8993 |
| 8994 } // namespace blink | 8994 } // namespace blink |
| OLD | NEW |