| 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 TestWebRemoteFrameClientForVisibility : public FrameTestHelpers::TestWebRe
moteFrameClient { |
| 8361 public: |
| 8362 TestWebRemoteFrameClientForVisibility() |
| 8363 : m_visible(true) |
| 8364 { |
| 8365 } |
| 8366 void visibilityChanged(bool visible) override { m_visible = visible; } |
| 8367 |
| 8368 bool isVisible() const { return m_visible; } |
| 8369 |
| 8370 private: |
| 8371 bool m_visible; |
| 8372 }; |
| 8373 |
| 8374 class WebFrameVisibilityChangeTest : public WebFrameTest { |
| 8375 public: |
| 8376 WebFrameVisibilityChangeTest() |
| 8377 { |
| 8378 registerMockedHttpURLLoad("visible_iframe.html"); |
| 8379 registerMockedHttpURLLoad("single_iframe.html"); |
| 8380 m_frame = m_webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.h
tml", true)->mainFrame(); |
| 8381 m_webRemoteFrame = remoteFrameClient()->frame(); |
| 8382 } |
| 8383 |
| 8384 ~WebFrameVisibilityChangeTest() |
| 8385 { |
| 8386 } |
| 8387 |
| 8388 void executeScriptOnMainFrame(const WebScriptSource& script) |
| 8389 { |
| 8390 mainFrame()->executeScript(script); |
| 8391 mainFrame()->view()->updateAllLifecyclePhases(); |
| 8392 runPendingTasks(); |
| 8393 } |
| 8394 |
| 8395 void swapLocalFrameToRemoteFrame() |
| 8396 { |
| 8397 mainFrame()->lastChild()->swap(remoteFrame()); |
| 8398 remoteFrame()->setReplicatedOrigin(SecurityOrigin::createUnique()); |
| 8399 } |
| 8400 |
| 8401 WebFrame* mainFrame() { return m_frame; } |
| 8402 WebRemoteFrameImpl* remoteFrame() { return m_webRemoteFrame; } |
| 8403 TestWebRemoteFrameClientForVisibility* remoteFrameClient() { return &m_remot
eFrameClient; } |
| 8404 |
| 8405 private: |
| 8406 TestWebRemoteFrameClientForVisibility m_remoteFrameClient; |
| 8407 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 8408 WebFrame* m_frame; |
| 8409 WebRemoteFrameImpl* m_webRemoteFrame; |
| 8410 }; |
| 8411 |
| 8412 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameVisibilityChange) |
| 8413 { |
| 8414 swapLocalFrameToRemoteFrame(); |
| 8415 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').s
tyle.display = 'none';")); |
| 8416 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
| 8417 |
| 8418 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').s
tyle.display = 'block';")); |
| 8419 EXPECT_TRUE(remoteFrameClient()->isVisible()); |
| 8420 } |
| 8421 |
| 8422 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
| 8423 { |
| 8424 swapLocalFrameToRemoteFrame(); |
| 8425 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); |
| 8426 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
| 8427 } |
| 8428 |
| 8360 } // namespace blink | 8429 } // namespace blink |
| OLD | NEW |