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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/js/resources/message.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/web_state_impl_unittest.mm
diff --git a/ios/web/web_state/web_state_impl_unittest.mm b/ios/web/web_state/web_state_impl_unittest.mm
index a2eb6d079c7d4d264724abf7d1f39001d3354293..41ccbf87c0ecf224b6fb1a03ce862f2c71bd5f08 100644
--- a/ios/web/web_state/web_state_impl_unittest.mm
+++ b/ios/web/web_state/web_state_impl_unittest.mm
@@ -603,5 +603,31 @@ TEST_F(WebStateTest, LoadingProgress) {
});
}
+// Tests that page which overrides window.webkit object does not break the
+// messaging system.
+TEST_F(WebStateTest, OverridingWebKitObject) {
+ // Add a script command handler.
+ __block bool message_received = false;
+ const web::WebState::ScriptCommandCallback callback =
+ base::BindBlock(^bool(const base::DictionaryValue&, const GURL&, bool) {
+ message_received = true;
+ return true;
+ });
+ web_state_->AddScriptCommandCallback(callback, "test");
+
+ // Load the page which overrides window.webkit object and wait until the
+ // test message is received.
+ LoadHtml(
+ "<script>"
+ " webkit = undefined;"
+ " __gCrWeb.message.invokeOnHost({'command': 'test.webkit-overriding'});"
+ "</script>");
+
+ base::test::ios::WaitUntilCondition(^{
+ return message_received;
+ });
+ web_state_->RemoveScriptCommandCallback("test");
+}
+
} // namespace
} // namespace web
« 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