| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/web/web_state/web_state_impl.h" | 5 #include "ios/web/web_state/web_state_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 596 |
| 597 // Tests loading progress. | 597 // Tests loading progress. |
| 598 TEST_F(WebStateTest, LoadingProgress) { | 598 TEST_F(WebStateTest, LoadingProgress) { |
| 599 EXPECT_FLOAT_EQ(0.0, web_state_->GetLoadingProgress()); | 599 EXPECT_FLOAT_EQ(0.0, web_state_->GetLoadingProgress()); |
| 600 LoadHtml("<html></html>"); | 600 LoadHtml("<html></html>"); |
| 601 base::test::ios::WaitUntilCondition(^bool() { | 601 base::test::ios::WaitUntilCondition(^bool() { |
| 602 return web_state_->GetLoadingProgress() == 1.0; | 602 return web_state_->GetLoadingProgress() == 1.0; |
| 603 }); | 603 }); |
| 604 } | 604 } |
| 605 | 605 |
| 606 // Tests that page which overrides window.webkit object does not break the |
| 607 // messaging system. |
| 608 TEST_F(WebStateTest, OverridingWebKitObject) { |
| 609 // Add a script command handler. |
| 610 __block bool message_received = false; |
| 611 const web::WebState::ScriptCommandCallback callback = |
| 612 base::BindBlock(^bool(const base::DictionaryValue&, const GURL&, bool) { |
| 613 message_received = true; |
| 614 return true; |
| 615 }); |
| 616 web_state_->AddScriptCommandCallback(callback, "test"); |
| 617 |
| 618 // Load the page which overrides window.webkit object and wait until the |
| 619 // test message is received. |
| 620 LoadHtml( |
| 621 "<script>" |
| 622 " webkit = undefined;" |
| 623 " __gCrWeb.message.invokeOnHost({'command': 'test.webkit-overriding'});" |
| 624 "</script>"); |
| 625 |
| 626 base::test::ios::WaitUntilCondition(^{ |
| 627 return message_received; |
| 628 }); |
| 629 web_state_->RemoveScriptCommandCallback("test"); |
| 630 } |
| 631 |
| 606 } // namespace | 632 } // namespace |
| 607 } // namespace web | 633 } // namespace web |
| OLD | NEW |