Skip to content

Commit

Permalink
Remove __gCrWeb.windowId
Browse files Browse the repository at this point in the history
__gCrWeb.windowId was used to ensure that JavaScript was executed on
the intended webpage. This is important because some scripts may deal
with user information. Such information is now all passed through
APIs using WebKit's FrameInfo instance which also has the same
guarantee because FrameInfo instances are tied to a particular
navigation.

Fixed: 905939

Change-Id: I19a2e0a7a7ef0f737af99962ec41294c5cbbbd04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189036
Reviewed-by: Ali Juma <ajuma@chromium.org>
Reviewed-by: Sergio Collazos <sczs@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096265}
  • Loading branch information
michaeldo1 authored and Chromium LUCI CQ committed Jan 24, 2023
1 parent 9ede207 commit 0660111
Show file tree
Hide file tree
Showing 24 changed files with 48 additions and 466 deletions.
14 changes: 7 additions & 7 deletions ios/chrome/browser/passwords/password_controller_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1105,23 +1105,23 @@ PasswordForm MakeSimpleForm() {
"Should show all suggestions when focusing empty username field",
@[(@"var evt = document.createEvent('Events');"
"username_.focus();"),
@""],
@";"],
@[@"user0 ••••••••", @"abc ••••••••"],
@"[]=, onkeyup=false, onchange=false"
},
{
"Should show password suggestions when focusing password field",
@[(@"var evt = document.createEvent('Events');"
"password_.focus();"),
@""],
@";"],
@[@"user0 ••••••••", @"abc ••••••••"],
@"[]=, onkeyup=false, onchange=false"
},
{
"Should not filter suggestions when focusing username field with input",
@[(@"username_.value='ab';"
"username_.focus();"),
@""],
@";"],
@[@"user0 ••••••••", @"abc ••••••••"],
@"ab[]=, onkeyup=false, onchange=false"
},
Expand All @@ -1132,7 +1132,7 @@ PasswordForm MakeSimpleForm() {
// Keyup event is dispatched to simulate typing
"var ev = new KeyboardEvent('keyup', {bubbles:true});"
"username_.dispatchEvent(ev);"),
@""],
@";"],
@[@"abc ••••••••"],
@"ab[]=, onkeyup=true, onchange=false"
},
Expand All @@ -1144,7 +1144,7 @@ PasswordForm MakeSimpleForm() {
// Keyup event is dispatched to simulate typing.
"var ev = new KeyboardEvent('keyup', {bubbles:true});"
"password_.dispatchEvent(ev);"),
@""],
@";"],
@[],
@"abc[]=••, onkeyup=true, onchange=false"
},
Expand Down Expand Up @@ -1600,15 +1600,15 @@ void SetUp() override {
"Should not show suggest password when focusing username field",
@[(@"var evt = document.createEvent('Events');"
"username_.focus();"),
@""],
@";"],
@[@"user0 ••••••••", @"abc ••••••••"],
@"[]=, onkeyup=false, onchange=false"
},
{
"Should show suggest password when focusing password field",
@[(@"var evt = document.createEvent('Events');"
"password_.focus();"),
@""],
@";"],
@[@"user0 ••••••••", @"abc ••••••••", @"Suggest Password\u2026"],
@"[]=, onkeyup=false, onchange=false"
},
Expand Down
7 changes: 0 additions & 7 deletions ios/chrome/test/earl_grey/chrome_earl_grey.mm
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,6 @@ - (void)loadURL:(const GURL&)URL waitForCompletion:(BOOL)wait {
if (wait) {
[self waitForWebStateVisible];
[self waitForPageToFinishLoading];
EG_TEST_HELPER_ASSERT_TRUE(
[ChromeEarlGreyAppInterface waitForWindowIDInjectionIfNeeded],
@"WindowID failed to inject");
// Loading URL (especially the first time) can trigger alerts.
[SystemAlertHandler handleSystemAlertIfVisible];
}
Expand Down Expand Up @@ -1028,10 +1025,6 @@ - (void)loadURL:(const GURL&)URL
inWindowWithNumber:windowNumber];
if (wait) {
[self waitForPageToFinishLoadingInWindowWithNumber:windowNumber];
EG_TEST_HELPER_ASSERT_TRUE(
[ChromeEarlGreyAppInterface
waitForWindowIDInjectionIfNeededInWindowWithNumber:windowNumber],
@"WindowID failed to inject");
// Loading URL (especially the first time) can trigger alerts.
[SystemAlertHandler handleSystemAlertIfVisible];
}
Expand Down
10 changes: 0 additions & 10 deletions ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@
// ui::PAGE_TRANSITION_TYPED and returns without waiting for the page to load.
+ (void)startLoadingURL:(NSString*)spec;

// If the current WebState is HTML content, will wait until the window ID is
// injected. Returns YES if the injection is successful or if the WebState is
// not HTML content.
+ (BOOL)waitForWindowIDInjectionIfNeeded;

// Returns YES if the current WebState is loading.
+ (BOOL)isLoading;

Expand Down Expand Up @@ -215,11 +210,6 @@
// Returns YES if the current WebState in window with given number is loading.
+ (BOOL)isLoadingInWindowWithNumber:(int)windowNumber [[nodiscard]];

// If the current WebState in window with given number is HTML content, will
// wait until the window ID is injected. Returns YES if the injection is
// successful or if the WebState is not HTML content.
+ (BOOL)waitForWindowIDInjectionIfNeededInWindowWithNumber:(int)windowNumber;

// Returns YES if the current WebState in window with given number contains
// `text`.
+ (BOOL)webStateContainsText:(NSString*)text
Expand Down
22 changes: 0 additions & 22 deletions ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
#import "ios/web/public/js_messaging/web_frame.h"
#import "ios/web/public/js_messaging/web_frame_util.h"
#import "ios/web/public/navigation/navigation_manager.h"
#import "ios/web/public/test/earl_grey/js_test_util.h"
#import "ios/web/public/test/element_selector.h"
#import "ios/web/public/test/url_test_util.h"
#import "ios/web/public/test/web_view_content_test_util.h"
Expand Down Expand Up @@ -194,16 +193,6 @@ + (void)startLoadingURL:(NSString*)spec {
chrome_test_util::LoadUrl(GURL(base::SysNSStringToUTF8(spec)));
}

+ (BOOL)waitForWindowIDInjectionIfNeeded {
web::WebState* webState = chrome_test_util::GetCurrentWebState();

if (webState->ContentIsHTML()) {
return web::WaitUntilWindowIdInjected(webState);
}

return YES;
}

+ (bool)isLoading {
return chrome_test_util::IsLoading();
}
Expand Down Expand Up @@ -507,17 +496,6 @@ + (BOOL)isLoadingInWindowWithNumber:(int)windowNumber {
return chrome_test_util::IsLoadingInWindowWithNumber(windowNumber);
}

+ (BOOL)waitForWindowIDInjectionIfNeededInWindowWithNumber:(int)windowNumber {
web::WebState* webState =
chrome_test_util::GetCurrentWebStateForWindowWithNumber(windowNumber);

if (webState->ContentIsHTML()) {
return web::WaitUntilWindowIdInjected(webState);
}

return YES;
}

+ (BOOL)webStateContainsText:(NSString*)text
inWindowWithNumber:(int)windowNumber {
web::WebState* webState =
Expand Down
8 changes: 0 additions & 8 deletions ios/web/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ source_set("web") {
deps = [
":common_js",
":core",
":js_resources",
":message_js",
":navigation_resources",
":plugin_placeholder_js",
Expand Down Expand Up @@ -118,8 +117,6 @@ source_set("eg_app_support+eg2") {
]

sources = [
"public/test/earl_grey/js_test_util.h",
"public/test/earl_grey/js_test_util.mm",
"public/test/earl_grey/web_view_actions.h",
"public/test/earl_grey/web_view_actions.mm",
"public/test/earl_grey/web_view_matchers.h",
Expand Down Expand Up @@ -666,11 +663,6 @@ optimize_js("message_js") {
sources = [ "js_messaging/resources/message.js" ]
}

optimize_js("js_resources") {
primary_script = "js_messaging/resources/window_id.js"
sources = [ "js_messaging/resources/window_id.js" ]
}

bundle_data("navigation_resources") {
sources = [
"navigation/resources/error_page_injected.html",
Expand Down
3 changes: 0 additions & 3 deletions ios/web/js_messaging/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ source_set("js_messaging") {
]

sources = [
"crw_js_window_id_manager.h",
"crw_js_window_id_manager.mm",
"page_script_util.h",
"page_script_util.mm",
"web_frame_impl.h",
Expand Down Expand Up @@ -181,7 +179,6 @@ source_set("unittests") {
]

sources = [
"crw_js_window_id_manager_unittest.mm",
"java_script_content_world_unittest.mm",
"java_script_feature_manager_unittest.mm",
"java_script_feature_unittest.mm",
Expand Down
29 changes: 0 additions & 29 deletions ios/web/js_messaging/crw_js_window_id_manager.h

This file was deleted.

125 changes: 0 additions & 125 deletions ios/web/js_messaging/crw_js_window_id_manager.mm

This file was deleted.

0 comments on commit 0660111

Please sign in to comment.