| 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 8339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8350 }; | 8350 }; |
| 8351 | 8351 |
| 8352 TEST_F(WebFrameTest, CallbackOrdering) | 8352 TEST_F(WebFrameTest, CallbackOrdering) |
| 8353 { | 8353 { |
| 8354 registerMockedHttpURLLoad("foo.html"); | 8354 registerMockedHttpURLLoad("foo.html"); |
| 8355 FrameTestHelpers::WebViewHelper webViewHelper; | 8355 FrameTestHelpers::WebViewHelper webViewHelper; |
| 8356 CallbackOrderingWebFrameClient client; | 8356 CallbackOrderingWebFrameClient client; |
| 8357 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); | 8357 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); |
| 8358 } | 8358 } |
| 8359 | 8359 |
| 8360 class WebFrameVisibilityChangeTest : public WebFrameTest { |
| 8361 public: |
| 8362 WebFrameVisibilityChangeTest() |
| 8363 { |
| 8364 registerMockedHttpURLLoad("visible_iframe.html"); |
| 8365 registerMockedHttpURLLoad("single_iframe.html"); |
| 8366 m_frame = m_webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.h
tml", true)->mainFrame(); |
| 8367 m_webRemoteFrame = remoteFrameClient()->frame(); |
| 8368 } |
| 8369 |
| 8370 ~WebFrameVisibilityChangeTest() |
| 8371 { |
| 8372 m_webViewHelper.reset(); |
| 8373 remoteFrame()->close(); |
| 8374 } |
| 8375 |
| 8376 void executeScriptOnMainFrame(const WebScriptSource& script) |
| 8377 { |
| 8378 mainFrame()->executeScript(script); |
| 8379 mainFrame()->view()->updateAllLifecyclePhases(); |
| 8380 runPendingTasks(); |
| 8381 } |
| 8382 |
| 8383 void swapLocalFrameToRemoteFrame() |
| 8384 { |
| 8385 mainFrame()->lastChild()->swap(remoteFrame()); |
| 8386 remoteFrame()->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| 8387 } |
| 8388 |
| 8389 WebFrame* mainFrame() { return m_frame; } |
| 8390 WebRemoteFrameImpl* remoteFrame() { return m_webRemoteFrame; } |
| 8391 FrameTestHelpers::TestWebRemoteFrameClientForVisibility* remoteFrameClient()
{ return &m_remoteFrameClient; } |
| 8392 |
| 8393 private: |
| 8394 FrameTestHelpers::TestWebRemoteFrameClientForVisibility m_remoteFrameClient; |
| 8395 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 8396 WebFrame* m_frame; |
| 8397 WebRemoteFrameImpl* m_webRemoteFrame; |
| 8398 }; |
| 8399 |
| 8400 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameVisibilityChange) |
| 8401 { |
| 8402 swapLocalFrameToRemoteFrame(); |
| 8403 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').s
tyle.display = 'none';")); |
| 8404 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
| 8405 |
| 8406 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').s
tyle.display = 'block';")); |
| 8407 EXPECT_TRUE(remoteFrameClient()->isVisible()); |
| 8408 } |
| 8409 |
| 8410 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
| 8411 { |
| 8412 swapLocalFrameToRemoteFrame(); |
| 8413 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); |
| 8414 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
| 8415 } |
| 8416 |
| 8360 } // namespace blink | 8417 } // namespace blink |
| OLD | NEW |