| 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());
|
|
|
|
|