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

Issue 2478803003: Remove DOMAutomationController::automation_id_ (Closed)

Created:
4 years, 1 month ago by Łukasz Anforowicz
Modified:
3 years, 5 months ago
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, jam, darin-cc_chromium.org, mlamouri+watch-geolocation_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove DOMAutomationController::automation_id_ Main change in this CL ====================== For a long time now the DOMAutomationController::automation_id_ value has not been used for its original purpose (associating sends with particular "jobs" / "automations" / render_views). Right now, the argument of domAutomationController::send is always routed back to WebContents (not to any more granular/specific destination). Right now the DOMAutomationController::automation_id_ field is still used to enable/disable domAutomationController::send - the send only works if setAutomationId was called previously (with a value different than MSG_ROUTING_NONE). In fact - in almost all cases, the scripts say: domAutomationController.setAutomationId(0) domAutomationController.send(...) This CL removes DOMAutomationController::automation_id_ field and makes domAutomationController.send work unconditionally. After this CL lands, we will be able to remove all calls to setAutomationId (after this CL they will be no-ops). Other changes needed by this CL =============================== The CL needed to make the following, additional fixes: 1. ExecuteScript (in content/public/test/browser_test_utils.h / .cc) appends "; domAutomationController.send(0);" to the script provided by the caller. This extra value would be usually ignored before this CL, but gets in the way after this CL (e.g. can get confused with other calls to domAutomationController.send(...)). To account for this a new ExecuteScriptAsync function has been provided in this CL. Ideally ExecuteScript would become ExecuteScriptAsync, but there are multiple tests that depend on the extra pumping of the message loop that happens in ExecuteScript and not in ExecuteScriptAsync. Therefore, ExecuteScriptAsync is a lesser evil, that minimizes amount of changes needed right now. To make sure that ExecuteScript stops waiting after the call to |domAutomationController.send(...)| that is added by ExecuteScript (and not by some other, accidental send) this CL sends a GUID that is unique in each call to ExecuteScript and verifies that the same GUID has been received back. This change has flushed out a few additional cases where ExecuteScriptAsync needs to be used as well as cases where a call to domAutomationController.send can be removed. The following callers of ExecuteScript had to be switched to call ExecuteScriptAsync instead: - ExecuteWebUIResourceTest (consumes messages via DOMMessageQueue and relies on the fact that this queue is not stumped upon). Additionally, it turned out that client_renderer.js and media_internals.js (used by WebUIResourceBrowserTest tests) were always erroring out before this CL (this has gone unnoticed, because the "FAILURE" string would have been eaten by ExecuteScript). - SecurityExploitBrowserTest.InterstitialCommandFromUnderlyingContent (otherwise the artificual "0" ends up in interstitial->last_command()). - captive_portal_browsertest.cc (otherwise we trigger a CHECK in captive_portal_blocking_page.cc: Command 0 isn't handled by the captive portal interstitial). Note that CaptivePortalBrowserTest / ShowCaptivePortalInterstitialOnCertError was relying on message pumping done by ExecuteScript. This was fragile - the timing of exiting the message pump was not related to the timing of the event the test needs to wait for. This was broken after going through ExecuteScriptAsync. This is fixed by introducing an explicit TabActivationWaiter. - ExecuteScriptInBackgroundPageNoWait (otherwise DOMMessageQueue used by ProcessManagerBrowserTest.ExtensionProcessReuse would have unexpectedly gotten a value sent by ExecuteScript, rather than the value send by the script itself; additionally, calling Execute*Unmodified*Script here makes sense in a function named "NoWait" - ExecuteScript would have waited). - saml_browsertest.cc - there was undesired interaction with listening to the value sent by SetupAuthFlowChangeListener. - ChromeSitePerProcessTest.PopupWindowFocus - this would conflict with domAutomationController.send from chrome/test/data/page_with_focus_events.html The following callers of ExecuteScript were needlessly calling domAutomationController.send from the script: - ProxyAuthOnUserBoardScreenTest.ProxyAuthDialogOnUserBoardScreen - WizardControllerTest::JSExecute - NavigationControllerBrowserTest.PostInSubframe - SitePerProcessBrowserTest.NavigateRemoteFrameToBlankAndDataURLs 2. autofill_interactive_uitest.cc used to call domAutomationController.send(true) from onfocus DOM event handlers. This would confuse expectations of ExecuteScriptAndExtractInt running "domAutomationController.send(42)" (it would sometimes receive a boolean rather than int back). This is fixed by using a one-time onfocus handlers (rather than permanent handlers) from FocusFieldByName method. 3. After the changes some GeolocationBrowserTest would receive "geoposition-updated" message twice - once from the geoSuccessCallbackWithResponse callback (from chrome/test/data/geolocation/basic_geolocation.js) and once from a checkIfGeopositionUpdated function. There is no need to resolve the race via checkIfGeopositionUpdated if we start listening (via DOMMessageQueue) *before* trigerring an update in the geo position. This way we can keep just the callback and remove the no longer needed checkIfGeopositionUpdated function. 4. content::IsWebcamAvailableOnSystem (via kHasVideoInputDeviceOnSystem) would call domAutomationController.send(...) twice before this CL. After this CL it is only called once. Other, opportunistic changes ============================ I've noticed that DOMMessageQueue::message_loop_runner_ can be null and therefore uses of this field need to be guarded. This required remembering result of DOMMessageQueue::RenderProcessGone, so that it still has an effect when there was no runner when the renderer crash notification happened. BUG=662543 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2478803003 Cr-Commit-Position: refs/heads/master@{#485461} Committed: https://chromium.googlesource.com/chromium/src/+/c7d6bd3d4561ae85c1e2baf25136e930aa33b055

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : . #

Patch Set 4 : . #

Patch Set 5 : . #

Patch Set 6 : Fix ExecuteScriptInBackgroundPageNoWait so it is truly "NoWait". #

Patch Set 7 : Fix kHasVideoInputDeviceOnSystem. #

Patch Set 8 : . #

Patch Set 9 : Rebasing... #

Total comments: 4

Patch Set 10 : Rebasing... #

Patch Set 11 : Addressed CR feedback from nick@. #

Patch Set 12 : Minor changes for things caught by a self-review. #

Patch Set 13 : Fixing issues caught by extra |expected_response| checks in ExecuteScript function. #

Total comments: 1

Patch Set 14 : More of: Fixing issues caught by extra |expected_response| checks in ExecuteScript function. #

Total comments: 8

Patch Set 15 : TabActivationWaiter tweaks. Better comments in browser_test_utils.h #

Total comments: 4

Patch Set 16 : Added |actual_response| checks to ExecuteScriptWithoutUserGesture. s/ExecuteUnmodifiedScript/Execu… #

Total comments: 2

Patch Set 17 : Rebasing... #

Unified diffs Side-by-side diffs Delta from patch set Stats (+223 lines, -150 lines) Patch
M chrome/browser/autofill/autofill_interactive_uitest.cc View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +20 lines, -24 lines 0 comments Download
M chrome/browser/captive_portal/captive_portal_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 8 chunks +56 lines, -10 lines 0 comments Download
M chrome/browser/chrome_site_per_process_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/chromeos/login/proxy_auth_dialog_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -3 lines 0 comments Download
M chrome/browser/chromeos/login/saml/saml_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +10 lines, -11 lines 0 comments Download
M chrome/browser/chromeos/login/wizard_controller_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +2 lines, -4 lines 0 comments Download
M chrome/browser/extensions/browsertest_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/geolocation/geolocation_browsertest.cc View 1 2 3 4 1 chunk +6 lines, -9 lines 0 comments Download
M chrome/test/data/geolocation/basic_geolocation.js View 2 chunks +1 line, -5 lines 0 comments Download
M chrome/test/data/geolocation/two_watches.html View 1 chunk +0 lines, -5 lines 0 comments Download
M content/browser/frame_host/navigation_controller_impl_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -2 lines 0 comments Download
M content/browser/resources/media/client_renderer.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +19 lines, -10 lines 0 comments Download
M content/browser/resources/media/media_internals.js View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/security_exploit_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/site_per_process_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 6 chunks +9 lines, -16 lines 0 comments Download
M content/public/test/browser_test_utils.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +30 lines, -8 lines 0 comments Download
M content/public/test/browser_test_utils.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 10 chunks +60 lines, -27 lines 0 comments Download
M content/renderer/dom_automation_controller.h View 1 2 3 4 1 chunk +0 lines, -2 lines 0 comments Download
M content/renderer/dom_automation_controller.cc View 1 2 3 4 5 chunks +1 line, -9 lines 0 comments Download

Messages

Total messages: 99 (81 generated)
Łukasz Anforowicz
nick@, could you PTAL? This CL makes domAutomationController.setAutomationId a no-op and paves way for removing ...
3 years, 5 months ago (2017-06-26 16:29:10 UTC) #40
ncarter (slow)
lgtm https://codereview.chromium.org/2478803003/diff/160001/content/public/test/browser_test_utils.cc File content/public/test/browser_test_utils.cc (right): https://codereview.chromium.org/2478803003/diff/160001/content/public/test/browser_test_utils.cc#newcode423 content/public/test/browser_test_utils.cc:423: window.domAutomationController.send('has-video-input-device'); looks like there could still be multiple ...
3 years, 5 months ago (2017-07-05 20:30:45 UTC) #45
Łukasz Anforowicz
https://codereview.chromium.org/2478803003/diff/160001/content/public/test/browser_test_utils.cc File content/public/test/browser_test_utils.cc (right): https://codereview.chromium.org/2478803003/diff/160001/content/public/test/browser_test_utils.cc#newcode423 content/public/test/browser_test_utils.cc:423: window.domAutomationController.send('has-video-input-device'); On 2017/07/05 20:30:44, ncarter (slow) wrote: > looks ...
3 years, 5 months ago (2017-07-06 15:48:02 UTC) #63
Łukasz Anforowicz
mathp@, alemate@, benwells@, mmenke@, could you PTAL for an OWNERS review? mathp: chrome/browser/autofill/autofill_interactive_uitest.cc alemate: chrome/browser/chromeos/login/proxy_auth_dialog_browsertest.cc ...
3 years, 5 months ago (2017-07-06 15:51:21 UTC) #64
Łukasz Anforowicz
mathp@, alemate@, benwells@, mmenke@, could you PTAL for an OWNERS review? mathp: chrome/browser/autofill/autofill_interactive_uitest.cc alemate: chrome/browser/chromeos/login/proxy_auth_dialog_browsertest.cc ...
3 years, 5 months ago (2017-07-06 15:52:12 UTC) #66
mmenke
https://codereview.chromium.org/2478803003/diff/260001/chrome/browser/captive_portal/captive_portal_browsertest.cc File chrome/browser/captive_portal/captive_portal_browsertest.cc (right): https://codereview.chromium.org/2478803003/diff/260001/chrome/browser/captive_portal/captive_portal_browsertest.cc#newcode905 chrome/browser/captive_portal/captive_portal_browsertest.cc:905: void WaitUntilActiveTabChanges() { Suggestion: Wait for a single change, ...
3 years, 5 months ago (2017-07-06 16:10:34 UTC) #67
Łukasz Anforowicz
mmenke@ - thanks for the comments. Can you take another look please? https://codereview.chromium.org/2478803003/diff/260001/chrome/browser/captive_portal/captive_portal_browsertest.cc File chrome/browser/captive_portal/captive_portal_browsertest.cc ...
3 years, 5 months ago (2017-07-06 16:46:56 UTC) #68
mmenke
captive_portal LGTM!
3 years, 5 months ago (2017-07-06 17:10:38 UTC) #71
Mathieu
autofill lgtm, could this have previously made things flaky? we've been having difficulties with the ...
3 years, 5 months ago (2017-07-06 17:25:16 UTC) #72
Łukasz Anforowicz
On 2017/07/06 17:25:16, Mathieu wrote: > autofill lgtm, could this have previously made things flaky? ...
3 years, 5 months ago (2017-07-06 17:34:23 UTC) #73
ncarter (slow)
https://codereview.chromium.org/2478803003/diff/280001/content/public/test/browser_test_utils.cc File content/public/test/browser_test_utils.cc (right): https://codereview.chromium.org/2478803003/diff/280001/content/public/test/browser_test_utils.cc#newcode843 content/public/test/browser_test_utils.cc:843: std::string new_script = script + ";window.domAutomationController.send(0);"; Should this match ...
3 years, 5 months ago (2017-07-06 18:14:31 UTC) #76
Łukasz Anforowicz
Thanks Nick. https://codereview.chromium.org/2478803003/diff/280001/content/public/test/browser_test_utils.cc File content/public/test/browser_test_utils.cc (right): https://codereview.chromium.org/2478803003/diff/280001/content/public/test/browser_test_utils.cc#newcode843 content/public/test/browser_test_utils.cc:843: std::string new_script = script + ";window.domAutomationController.send(0);"; On ...
3 years, 5 months ago (2017-07-06 20:11:02 UTC) #82
ncarter (slow)
lgtm thanks again for taking on this longstanding wart
3 years, 5 months ago (2017-07-06 21:40:11 UTC) #83
benwells
lgtm with a little nit https://codereview.chromium.org/2478803003/diff/300001/chrome/browser/geolocation/geolocation_browsertest.cc File chrome/browser/geolocation/geolocation_browsertest.cc (right): https://codereview.chromium.org/2478803003/diff/300001/chrome/browser/geolocation/geolocation_browsertest.cc#newcode416 chrome/browser/geolocation/geolocation_browsertest.cc:416: content::DOMMessageQueue dom_message_queue; Nit: can ...
3 years, 5 months ago (2017-07-10 05:30:50 UTC) #88
Łukasz Anforowicz
Thanks Ben, and my apologies for not providing enough detail in the CL description. I've ...
3 years, 5 months ago (2017-07-10 14:54:18 UTC) #91
Alexander Alekseev
lgtm
3 years, 5 months ago (2017-07-10 22:32:33 UTC) #92
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2478803003/320001
3 years, 5 months ago (2017-07-10 22:52:57 UTC) #95
commit-bot: I haz the power
3 years, 5 months ago (2017-07-11 00:20:13 UTC) #99
Message was sent while issue was closed.
Committed patchset #17 (id:320001) as
https://chromium.googlesource.com/chromium/src/+/c7d6bd3d4561ae85c1e2baf25136...

Powered by Google App Engine
This is Rietveld 408576698