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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2683583003: Bindings: perform security check before downcasting to LocalDOMWindow. (Closed)
Patch Set: . Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 1d4b2d7f62e54dfae394ccea919bfff5c69bcbc4..1940ba8eb8df55f04512588a4d003738dcc96615 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -8470,7 +8470,7 @@ class WebFrameSwapTest : public WebFrameTest {
void reset() { m_webViewHelper.reset(); }
WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); }
- WebView* webView() const { return m_webViewHelper.webView(); }
+ WebViewImpl* webView() const { return m_webViewHelper.webView(); }
private:
FrameTestHelpers::WebViewHelper m_webViewHelper;
@@ -8816,6 +8816,40 @@ TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext) {
reset();
}
+TEST_F(WebFrameSwapTest, SetTimeoutAfterSwap) {
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ mainFrame()->executeScript(
+ WebScriptSource("savedSetTimeout = window[0].setTimeout"));
+
+ // Swap the frame to a remote frame.
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ WebRemoteFrame* remoteFrame = remoteClient.frame();
+ WebFrame* targetFrame = mainFrame()->firstChild();
+ targetFrame->swap(remoteFrame);
+ remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
+
+ // Invoking setTimeout should throw a security error.
+ {
+ v8::Local<v8::Value> exception = mainFrame()->executeScriptAndReturnValue(
+ WebScriptSource("try {\n"
+ " savedSetTimeout.call(window[0], () => {}, 0);\n"
+ "} catch (e) { e; }"));
+ ASSERT_TRUE(!exception.IsEmpty());
+ EXPECT_EQ(
+ "SecurityError: Failed to execute 'setTimeout' on 'Window': Blocked a "
+ "frame with origin \"http://internal.test\" from accessing a "
+ "cross-origin frame.",
+ toCoreString(exception
+ ->ToString(ScriptState::forMainWorld(
+ webView()->mainFrameImpl()->frame())
+ ->context())
+ .ToLocalChecked()));
+ }
+
+ reset();
+}
+
TEST_F(WebFrameSwapTest, SwapInitializesGlobal) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698