diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
commit | 3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch) | |
tree | 73dc228333948738bbe02976cacca8cd382bc978 /Source/WebKit/chromium/tests/WebFrameTest.cpp | |
parent | b32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff) | |
download | qtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz |
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
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 |