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 6896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6907 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource( | 6907 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource( |
6908 "document.querySelector('#frame2').contentWindow.top;")); | 6908 "document.querySelector('#frame2').contentWindow.top;")); |
6909 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); | 6909 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
6910 | 6910 |
6911 // Manually reset to break WebViewHelper's dependency on the stack allocated | 6911 // Manually reset to break WebViewHelper's dependency on the stack allocated |
6912 // TestWebFrameClient. | 6912 // TestWebFrameClient. |
6913 reset(); | 6913 reset(); |
6914 remoteFrame->close(); | 6914 remoteFrame->close(); |
6915 } | 6915 } |
6916 | 6916 |
| 6917 TEST_F(WebFrameSwapTest, SwapInitializesGlobal) |
| 6918 { |
| 6919 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 6920 |
| 6921 v8::Local<v8::Value> windowTop = mainFrame()->executeScriptAndReturnValue(We
bScriptSource("window")); |
| 6922 ASSERT_TRUE(windowTop->IsObject()); |
| 6923 |
| 6924 v8::Local<v8::Value> lastChild = mainFrame()->executeScriptAndReturnValue(We
bScriptSource("saved = window[2]")); |
| 6925 ASSERT_TRUE(lastChild->IsObject()); |
| 6926 |
| 6927 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| 6928 WebRemoteFrame* remoteFrame = remoteClient.frame(); |
| 6929 mainFrame()->lastChild()->swap(remoteFrame); |
| 6930 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| 6931 v8::Local<v8::Value> remoteWindowTop = mainFrame()->executeScriptAndReturnVa
lue(WebScriptSource("saved.top")); |
| 6932 EXPECT_TRUE(remoteWindowTop->IsObject()); |
| 6933 EXPECT_TRUE(windowTop->StrictEquals(remoteWindowTop)); |
| 6934 |
| 6935 FrameTestHelpers::TestWebFrameClient client; |
| 6936 WebLocalFrame* localFrame = WebLocalFrame::create(&client); |
| 6937 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "", WebSandboxFlags:
:None); |
| 6938 remoteFrame->swap(localFrame); |
| 6939 v8::Local<v8::Value> localWindowTop = mainFrame()->executeScriptAndReturnVal
ue(WebScriptSource("saved.top")); |
| 6940 EXPECT_TRUE(localWindowTop->IsObject()); |
| 6941 EXPECT_TRUE(windowTop->StrictEquals(localWindowTop)); |
| 6942 |
| 6943 reset(); |
| 6944 } |
| 6945 |
6917 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) | 6946 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) |
6918 { | 6947 { |
6919 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6948 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
6920 | 6949 |
6921 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 6950 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
6922 WebRemoteFrame* remoteFrame = remoteClient.frame(); | 6951 WebRemoteFrame* remoteFrame = remoteClient.frame(); |
6923 mainFrame()->lastChild()->swap(remoteFrame); | 6952 mainFrame()->lastChild()->swap(remoteFrame); |
6924 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); | 6953 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); |
6925 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue
(WebScriptSource("window[2]")); | 6954 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue
(WebScriptSource("window[2]")); |
6926 EXPECT_TRUE(remoteWindow->IsObject()); | 6955 EXPECT_TRUE(remoteWindow->IsObject()); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7231 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); | 7260 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); |
7232 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); | 7261 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); |
7233 | 7262 |
7234 // Manually reset to break WebViewHelpers' dependencies on the stack | 7263 // Manually reset to break WebViewHelpers' dependencies on the stack |
7235 // allocated WebFrameClients. | 7264 // allocated WebFrameClients. |
7236 webViewHelper.reset(); | 7265 webViewHelper.reset(); |
7237 popupWebViewHelper.reset(); | 7266 popupWebViewHelper.reset(); |
7238 } | 7267 } |
7239 | 7268 |
7240 } // namespace blink | 7269 } // namespace blink |
OLD | NEW |