diff options
Diffstat (limited to 'Source/WebKit/chromium/tests/WebFrameTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/WebFrameTest.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index 9b745e029..cd23d6268 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -804,4 +804,54 @@ TEST_F(WebFrameTest, GetFullHtmlOfPage) EXPECT_TRUE(selectionHtml.isEmpty()); } +class TestExecuteScriptDuringDidCreateScriptContext : public WebFrameClient { +public: + virtual void didCreateScriptContext(WebFrame* frame, v8::Handle<v8::Context> context, int extensionGroup, int worldId) OVERRIDE + { + frame->executeScript(WebScriptSource("window.history = 'replaced';")); + } +}; + +TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) +{ + registerMockedHttpURLLoad("hello_world.html"); + + TestExecuteScriptDuringDidCreateScriptContext webFrameClient; + WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html", true, &webFrameClient); + + webView->mainFrame()->reload(); + webkit_support::ServeAsynchronousMockedRequests(); +} + +class TestDidCreateFrameWebFrameClient : public WebFrameClient { +public: + TestDidCreateFrameWebFrameClient() : m_frameCount(0), m_parent(0) + { + } + + virtual void didCreateFrame(WebFrame* parent, WebFrame* child) + { + m_frameCount++; + if (!m_parent) + m_parent = parent; + } + + int m_frameCount; + WebFrame* m_parent; +}; + +TEST_F(WebFrameTest, DidCreateFrame) +{ + registerMockedHttpURLLoad("iframes_test.html"); + registerMockedHttpURLLoad("visible_iframe.html"); + registerMockedHttpURLLoad("invisible_iframe.html"); + registerMockedHttpURLLoad("zero_sized_iframe.html"); + + TestDidCreateFrameWebFrameClient webFrameClient; + WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html", false, &webFrameClient); + + EXPECT_EQ(webFrameClient.m_frameCount, 3); + EXPECT_EQ(webFrameClient.m_parent, webView->mainFrame()); +} + } // namespace |