Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: ios/web/web_state/web_state_impl_unittest.mm

Issue 1973683002: [ios] Protect JS messaging system from window.webkit object overriding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/web_state/js/resources/message.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ios/web/web_state/js/resources/message.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698