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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 1112843007: Fix frameElement for frames with a remote parent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add comment about doing the access check on the frame vs node. Created 5 years, 7 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
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7009 matching lines...) Expand 10 before | Expand all | Expand 10 after
7020 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent)); 7020 EXPECT_TRUE(window->StrictEquals(childOfRemoteParent));
7021 7021
7022 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length")); 7022 v8::Local<v8::Value> windowLength = childFrame->executeScriptAndReturnValue( WebScriptSource("parent.frames.length"));
7023 ASSERT_TRUE(windowLength->IsInt32()); 7023 ASSERT_TRUE(windowLength->IsInt32());
7024 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value()); 7024 EXPECT_EQ(1, windowLength.As<v8::Int32>()->Value());
7025 7025
7026 // Manually reset to break WebViewHelper's dependency on the stack allocated clients. 7026 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7027 reset(); 7027 reset();
7028 } 7028 }
7029 7029
7030 // Check that frames with a remote parent don't crash while accessing window.fra meElement.
7031 TEST_F(WebFrameSwapTest, FrameElementInFramesWithRemoteParent)
7032 {
7033 v8::HandleScope scope(v8::Isolate::GetCurrent());
7034
7035 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7036 WebRemoteFrame* remoteParentFrame = remoteClient.frame();
7037 mainFrame()->swap(remoteParentFrame);
7038 remoteParentFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
7039
7040 FrameTestHelpers::TestWebFrameClient childFrameClient;
7041 WebLocalFrame* childFrame = remoteParentFrame->createLocalChild("", WebSandb oxFlags::None, &childFrameClient);
7042 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "subframe-hello.html");
7043
7044 v8::Local<v8::Value> frameElement = childFrame->executeScriptAndReturnValue( WebScriptSource("window.frameElement"));
7045 // frameElement shouldn't be accessible cross-origin.
7046 EXPECT_TRUE(frameElement.IsEmpty());
7047
7048 // Manually reset to break WebViewHelper's dependency on the stack allocated clients.
7049 reset();
7050 }
7051
7030 class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameCli ent { 7052 class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameCli ent {
7031 public: 7053 public:
7032 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) 7054 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame)
7033 : m_historyCommitType(WebHistoryInertCommit) 7055 : m_historyCommitType(WebHistoryInertCommit)
7034 , m_remoteFrame(remoteFrame) 7056 , m_remoteFrame(remoteFrame)
7035 { 7057 {
7036 } 7058 }
7037 7059
7038 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W ebHistoryCommitType historyCommitType) override 7060 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W ebHistoryCommitType historyCommitType) override
7039 { 7061 {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
7301 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); 7323 ASSERT_EQ(2u, popupWebFrameClient.messages.size());
7302 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame")); 7324 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame"));
7303 7325
7304 // Manually reset to break WebViewHelpers' dependencies on the stack 7326 // Manually reset to break WebViewHelpers' dependencies on the stack
7305 // allocated WebFrameClients. 7327 // allocated WebFrameClients.
7306 webViewHelper.reset(); 7328 webViewHelper.reset();
7307 popupWebViewHelper.reset(); 7329 popupWebViewHelper.reset();
7308 } 7330 }
7309 7331
7310 } // namespace blink 7332 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698