0
Commit Graph

42 Commits

Author SHA1 Message Date
Lei Zhang
05c13df891 Remove unnecessary ContentBrowserTest::SetUpCommandLine() calls
ContentBrowserTest::SetUpCommandLine() is actually not defined. Calls to
this method ends up running BrowserTestBase::SetUpCommandLine(), which
is always going to be empty. Since there is no point in calling this
method, delete all the callers from SetUpCommandLine() overrides. When
the override becomes empty, delete the override altogether.

Make a note of this in the comments in content_browser_test.h. Also fix
some lint errors along the way.

Change-Id: I81f263286d72ebdab68dfd9575ad4cf2b6378a3c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5691227
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1325736}
2024-07-10 20:59:12 +00:00
Jeremy Roman
1e4b31f4c3 Remove DocumentPolicy feature flags.
It has been shipped for over three years:
  https://chromium-review.googlesource.com/c/chromium/src/+/2331742

Bug: 1064579
Change-Id: I8b51542c1af757b1686d8e26b8c33940e3ebd4e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5012980
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1224528}
2023-11-14 20:56:47 +00:00
Rune Lillesveen
09a17df4a9 Disable flaky TextFragmentAnchorBrowserTests
Flaky on CrOS Debug

Bug: 1470712
Change-Id: I4cc450c44ef10bc7b7594f9fef095458045b9734
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4755610
Owners-Override: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Victor Tan <victortan@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1180277}
2023-08-07 14:19:09 +00:00
Rakina Zata Amni
364eb5dd32 Make various content_browsertests expect same-SiteInstance RenderFrameHost etc swap
With RenderDocument, cross-document navigations will use new
RenderFrameHosts (and RenderViewHosts, RenderWidgetHosts, etc for
main frame navigations). This CL updates some tests in
content_browsertests that didn't expect those changes.

Bug: 936696
Change-Id: Ia43799aaae9f50b7ff9c3221982b622d76698d14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4349554
Reviewed-by: James Maclean <wjmaclean@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Auto-Submit: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1120489}
2023-03-22 13:19:00 +00:00
Fergal Daly
83bc3cd44e Update callers to check return value of TestNavigationManager::Wait*
This is a no-op change to /content/browser to update all callers of
WaitForFirstYieldAfterDidStartNavigation and WaitForNavigationFinished
to check for success. Failure could be due to a test timeout or other
error in which case we should stop the test. Proceeding further with
the test will just produce confusing output.

The return values will be marked `[[nodiscard]]` in a follow-up
change.

This CL was uploaded by git cl split.

R=altimin@chromium.org

Bug: 1403181
Change-Id: Ifc67145b50e5befbd07e3c62878baf840f21e56b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4122187
Reviewed-by: Alexander Timin <altimin@chromium.org>
Commit-Queue: Fergal Daly <fergal@chromium.org>
Auto-Submit: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1093632}
2023-01-18 00:22:54 +00:00
Sean Maher
e672a665ff task posting v3: remove includes of runner handles and IWYU task runners
Turns out there's a lot of includes, so these will have to be removed
before deleting the implementation of the task runner handles.

To allow the deletion of the task runner handle headers, add
the sequenced/thread task runner handles where they are used in
the codebase with scripts.

This was done with an automated change, with a few touchups afterwards.
The code for the mass-refactor changes are here:
python:
https://paste.googleplex.com/5534570878337024
shell:
https://paste.googleplex.com/6466750748033024

In terms of touchups:
- add sequenced/thread task runner handles to
  the third_party/blink/public/DEPS, because multiple files were using
  it transitively anyways.
- rewrite certain parts of the codebase which used
  ThreadTaskRunnerHandles instead of CurrentDefaultHandles.
- fix a compile issue with forward-declaration in
  extensions/browser/extension_file_task_runner.h.

AX-Relnotes: n/a.
Bug: 1026641
Change-Id: I737ef32aee4e77c21eaa3a2bdc403a28322cf1b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4133323
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Sean Maher <spvw@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090532}
2023-01-09 21:42:28 +00:00
Sean Maher
5b9af51fdd task posting v3: moving away from ThreadTaskRunnerHandle
To continue the migration away from TaskRunnerHandles, the codebase
was refactored using the following scripts:
shell script:
https://paste.googleplex.com/4673967729147904
python:
https://paste.googleplex.com/5824001174667264

This will do a few sed-like modifications, changing calls to methods of
ThreadTaskRunnerHandle to calls to methods of
SingleThreadTaskRunner::CurrentDefaultHandle, and swapping includes.

Bug: 1026641
AX-Relnotes: n/a.
Change-Id: Ia33b6dfebb15937481c619f5c838720ce7bb2676
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4031817
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1074085}
2022-11-21 15:32:47 +00:00
Avi Drissman
4e1b7bc33d Update copyright headers in content/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I8c0f009d16350271f07d8e5e561085822cc9dd27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895935
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047456}
2022-09-15 14:03:50 +00:00
Dave Tapuska
327c06c9c7 Rename GetMainFrame to GetPrimaryMainFrame
Progressively rename some usages of GetMainFrame to GetPrimaryMainFrame.

This is an automated change via git grep & sed.

BUG=1250404

Change-Id: I5e8fda4f11104cf9fcde8a690a33dc6ab7c34f3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696741
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013636}
2022-06-13 20:31:51 +00:00
David Bokan
b2e47a14e1 Fix sequential focus in text fragment anchor
Sequential focus should start where the page was scrolled to. The
text fragment can have highlights further down the page so setting it
for each highlight means that focus may be well outside of the viewport
which may be surprising for users.

Change-Id: Ib7e6668c71a7b4d5790ce4742e42c219202cb4c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3633948
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Jeffrey Cohen <jeffreycohen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1005418}
2022-05-19 22:14:38 +00:00
Colin Blundell
ecd384fa19 [DOMMessageQueue] Convert content_browsertests to preferred constructor
This CL converts the remaining usages of the DOMMessageQueue default
constructor in content_browsertests to the one that takes in a
WebContents instance. The former listens for messages from all
WebContents instances via a notification, while the latter observes the
passed-in WebContents instance to listen for messages from that
instance. We are trying to eliminate the former entirely as part of the
elimination of NotificationService.

The conversions are for the most part straightforward; the one
exception is site_per_process_unload_browsertest.cc, in which we need
to catch a WebContents instance created via a popup to be able to listen
for messages that occur in that instance.

Bug: 1174774
Change-Id: Ieaf7d2811282e2a3c0c7dbbe95c58d2c7aeff20c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3635781
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001976}
2022-05-11 08:58:30 +00:00
Rakina Zata Amni
30af706d4f Update comment for and rename TEST_ASSUMES_NO_CACHING BFCache disabling reason
Tests that requires a document to not be bfcached are still valid even
when BFCache is enabled by default, so updating the comment for
TEST_ASSUMES_NO_CACHING that implies these tests are invalid.

Also renames TEST_ASSUMES_NO_CACHING to TEST_REQUIRES_NO_CACHING to be
more intentional (previously it was used to update existing tests with
outdated assumptions).

Change-Id: I4c54dc61177d7eaedeb18488000adf59a893612a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3271970
Auto-Submit: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Owners-Override: Alexander Timin <altimin@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/main@{#961186}
2022-01-19 23:46:36 +00:00
Carlos Caballero
15caeeb12d Rename WebContentsImpl::GetFrameTree to GetPrimaryFrameTree
Note that the old method is already returning the PrimaryFrameTree so
this patch is just about making that explicit.

Trivial change that renames all test files leaving the production code
for a later patch. That code will need a closer look to make sure that
call sites are really expecting the primary frame tree (note they are
already getting the primary frame tree, so this is just an extra check
for peace of mind).

Keeping the old method around for a while will also prevent this massive
patch from being reverted if an optional try-bot later fails.

Bug: 1251094
Change-Id: Ibc86aedf203013e41e61ede94e6af929f80ee477
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3231330
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Sreeja Kamishetty <sreejakshetty@chromium.org>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/main@{#935359}
2021-10-27 09:57:55 +00:00
sebsg
901c271dcb [SH] Fix LinkOpenSource metric bug.
Links opened from mail.google.com for example have the referrer set to
google.com. This leads to recording the link open source as being a
search engine even if it's not.

The reason is in two parts:
1- It seems the requestorOrigin is accurate in more case, so moving to
using that
2- Client-side redirects mess these up. We'll consider all cases with
client-side redirects to not come from search engine. Tested it on
major SEs and they did use client redirects.

Bug: 1256789
Change-Id: Ibad2d4a14ca6c05efa7b59c9d4396d1f3b3c907a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3205071
Reviewed-by: David Bokan <bokan@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: sebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#932684}
2021-10-18 21:12:52 +00:00
David Bokan
289abe0fd9 Fix flaky ForceLoadAtTopBrowserTest
The failing pattern was using RunUntilInputProcessed followed by
checking RenderFrameMetadata::is_scroll_offset_at_top.

RunUntilInputProcessed forces the renderer to generate a new frame and
waits until that frame is presented by the Viz process. However, the
renderer sends the RenderFrameMetadata to the browser at the same time
as it submits a compositor frame. If the Viz process displayed the
compositor frame before the browser processes processes the
RenderFrameMetadata message, RunUntilInputProcessed will be unblocked
before the metadata is updated, leading to the flake.

This CL replaces uses of is_scroll_offset_at_top by simply reading the
scroll offset via JS.

Bug: 1239636
Change-Id: I3cfff49151f6ce8e1dae9e85f2592acab84ed5af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3201694
Reviewed-by: Bo <boliu@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#927710}
2021-10-04 16:51:07 +00:00
David Bokan
aedd256979 Reland "Disable SameDocumentNavigation on Android."
This reverts commit 8d6cf97ce4.

Reason for revert: Confirmed this is still flaking

Original change's description:
> Revert "Disable SameDocumentNavigation on Android."
>
> This reverts commit a48131dc04.
>
> Reason for revert: Can't reproduce locally, reverting to confirm
> this is still flaky.
>
> Original change's description:
> > Disable SameDocumentNavigation on Android.
> >
> > Bug: 1239636
> > Change-Id: Ic854809499f2a106169dcfa9084a32e449d10e95
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3094445
> > Commit-Queue: Sky Malice <skym@chromium.org>
> > Commit-Queue: bttk <bttk@chromium.org>
> > Owners-Override: Sky Malice <skym@chromium.org>
> > Auto-Submit: Sky Malice <skym@chromium.org>
> > Reviewed-by: bttk <bttk@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#911753}
>
> Bug: 1239636
> Change-Id: I80164d2cd64d531232962604ddb9ec51ee406d52
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3182860
> Reviewed-by: Sky Malice <skym@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Commit-Queue: David Bokan <bokan@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#925412}

Bug: 1239636
Change-Id: If62256f8bd6931a622a45d1d36f8e6442d567485
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3188493
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Sky Malice <skym@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#925902}
2021-09-28 20:03:07 +00:00
David Bokan
8d6cf97ce4 Revert "Disable SameDocumentNavigation on Android."
This reverts commit a48131dc04.

Reason for revert: Can't reproduce locally, reverting to confirm
this is still flaky.

Original change's description:
> Disable SameDocumentNavigation on Android.
>
> Bug: 1239636
> Change-Id: Ic854809499f2a106169dcfa9084a32e449d10e95
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3094445
> Commit-Queue: Sky Malice <skym@chromium.org>
> Commit-Queue: bttk <bttk@chromium.org>
> Owners-Override: Sky Malice <skym@chromium.org>
> Auto-Submit: Sky Malice <skym@chromium.org>
> Reviewed-by: bttk <bttk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#911753}

Bug: 1239636
Change-Id: I80164d2cd64d531232962604ddb9ec51ee406d52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3182860
Reviewed-by: Sky Malice <skym@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#925412}
2021-09-27 20:50:43 +00:00
Sky Malice
a48131dc04 Disable SameDocumentNavigation on Android.
Bug: 1239636
Change-Id: Ic854809499f2a106169dcfa9084a32e449d10e95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3094445
Commit-Queue: Sky Malice <skym@chromium.org>
Commit-Queue: bttk <bttk@chromium.org>
Owners-Override: Sky Malice <skym@chromium.org>
Auto-Submit: Sky Malice <skym@chromium.org>
Reviewed-by: bttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#911753}
2021-08-13 15:43:30 +00:00
Dominique Fauteux-Chapleau
3e8d345132 Reland "Update content/ tests to handle same-site bfcache"
This reverts commit 2a0a50b08f.

Reason for revert: The revert of the original change
(crrev.com/c/3026285) caused new failures, so this relands the original
CL with a small change in patchset#4 where the failing tests in
crbug.com/1229182 are disabled.

Original change's description:
> Revert "Update content/ tests to handle same-site bfcache"
>
> This reverts commit fea922347e.
>
> Reason for revert: Breaks linux-chromeos-chrome, see crbug.com/1229182
>
> Original change's description:
> > Update content/ tests to handle same-site bfcache
> >
> > We're about to enable same-site bfcache on trybots (crrev.com/c/2842371)
> > so we need to update tests to handle same-site bfcache.
> >
> > Bug: 511340,1219373
> > Change-Id: I31f7395560711533d24603df12d2795ad82b7108
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2916456
> > Auto-Submit: Rakina Zata Amni <rakina@chromium.org>
> > Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
> > Reviewed-by: Fergal Daly <fergal@chromium.org>
> > Reviewed-by: Matt Falkenhagen <falken@chromium.org>
> > Reviewed-by: Alexander Timin <altimin@chromium.org>
> > Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#901350}
>
> Bug: 511340,1219373
> Change-Id: Ib893023f661a97b845d3ff8cb9fd4d426bd6d24f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3026285
> Reviewed-by: Dominique Fauteux-Chapleau <domfc@chromium.org>
> Reviewed-by: Dominique Fauteux-Chapleau <domfc@google.com>
> Owners-Override: Dominique Fauteux-Chapleau <domfc@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Dominique Fauteux-Chapleau <domfc@google.com>
> Cr-Commit-Position: refs/heads/master@{#901478}

Bug: 511340,1219373
Change-Id: Ib2e36d039e09f782989559662fbd6b3227adeb38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3024416
Reviewed-by: Dominique Fauteux-Chapleau <domfc@google.com>
Owners-Override: Dominique Fauteux-Chapleau <domfc@google.com>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#901530}
2021-07-14 17:20:02 +00:00
Dominique Fauteux-Chapleau
2a0a50b08f Revert "Update content/ tests to handle same-site bfcache"
This reverts commit fea922347e.

Reason for revert: Breaks linux-chromeos-chrome, see crbug.com/1229182

Original change's description:
> Update content/ tests to handle same-site bfcache
>
> We're about to enable same-site bfcache on trybots (crrev.com/c/2842371)
> so we need to update tests to handle same-site bfcache.
>
> Bug: 511340,1219373
> Change-Id: I31f7395560711533d24603df12d2795ad82b7108
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2916456
> Auto-Submit: Rakina Zata Amni <rakina@chromium.org>
> Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
> Reviewed-by: Fergal Daly <fergal@chromium.org>
> Reviewed-by: Matt Falkenhagen <falken@chromium.org>
> Reviewed-by: Alexander Timin <altimin@chromium.org>
> Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#901350}

Bug: 511340,1219373
Change-Id: Ib893023f661a97b845d3ff8cb9fd4d426bd6d24f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3026285
Reviewed-by: Dominique Fauteux-Chapleau <domfc@chromium.org>
Reviewed-by: Dominique Fauteux-Chapleau <domfc@google.com>
Owners-Override: Dominique Fauteux-Chapleau <domfc@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@google.com>
Cr-Commit-Position: refs/heads/master@{#901478}
2021-07-14 13:52:23 +00:00
Rakina Zata Amni
fea922347e Update content/ tests to handle same-site bfcache
We're about to enable same-site bfcache on trybots (crrev.com/c/2842371)
so we need to update tests to handle same-site bfcache.

Bug: 511340,1219373
Change-Id: I31f7395560711533d24603df12d2795ad82b7108
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2916456
Auto-Submit: Rakina Zata Amni <rakina@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Fergal Daly <fergal@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#901350}
2021-07-14 03:52:04 +00:00
Rakina Zata Amni
348fe2b499 Stop requiring destination URL to be HTTP(s) for proactive BI swap
Previously we will only do proactive BI swap if the destination URL is
HTTP/HTTPs. However this isn't really needed because we want to do
proactive BI swap to cache the previous page, instead of the
destination page. Since the contents of the destination page shouldn't
affect the bfcache eligibility of the previous page, this CL removes
the aforementioned check, and updates tests that do not expect BI/RFH
swap on navigations to about:blank, etc.

Change-Id: I46282c7665124b80bae663c80bdd5c1fa625d7b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3014135
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#899867}
2021-07-09 05:28:52 +00:00
John Abd-El-Malek
ea3ba3c016 Disable content_browsertests that fail on Android with BFCache field trial testing configs enabled.
Bug: 1219373
Change-Id: I16b92a42a0fe3a5f136486eda3b8c0b975bcaa53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2958785
Auto-Submit: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#892036}
2021-06-14 12:05:48 +00:00
David Bokan
a71830a90b Allow text fragments in same-document navigations
This CL lifts the restriction on text fragments in the specific case of
a same-document navigation initiated by an origin that's same-origin
with the current document. In this case, the two documents already have
full access to each other's content so text fragments present no risk.
Enabling them allows using anchor links to text-fragments on the current
page as well as allowing coordinating origins to pass a text-fragment
into an iframe.

To do this, we update DocumentLoader's |is_same_origin_navigation_|
member on same-document navigations (and we rename it to be more
specific that the initiator is same-origin or browser).

We also make another small adjustment in allowing text fragments to be
invoked on replacement navigations (e.g. location.replace) which don't
create a new history entry. This was simply an unintentional omission in
the implementation.

Change-Id: Id82f46294b87d12d6a7355e0f7e4936e7fae75d6
Bug: 1198668
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2811999
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Robert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#875755}
2021-04-23 18:22:13 +00:00
David Bokan
1501b6f146 Correctly determine browser-initiated navigation
In [1] we use the |is_content_initiated|
parameter in DocumentLoader::UpdateForSameDocumentNavigation in a way
that |!is_content_initiated| implies browser-initiated. However,
|is_content_initiated| is a misleading name, it's true only for content
initiated navigations that were synchronously initiated by this Blink
agent. A content-initiated navigation originating in another origin
would be posted to this agent and received in [2] where we set the
origin_window to nullptr[2]. This gets passed into
|is_content_initiated| as false.

Note, we do actually want the current semantics of
|is_content_initiated| in some cases, e.g. to know whether we need to
reply to the browser process for navigation bookkeeping.

Therefore, to know whether something is "browser-initiated" (e.g. typing
in the omnibox) we need to accurately track the initiator origin. This
CL plumbs that information through for same-document navigations.

[1] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/loader/document_loader.cc;l=698;drc=57544c227ec492b8574ec8163def47ff57d36511
[2] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/web_local_frame_impl.cc;l=2348;drc=57544c227ec492b8574ec8163def47ff57d36511

Bug: 1198670
Change-Id: Ib318ae468c4ae100b8d4fe13a8e804d20d86ef27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2822081
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#874495}
2021-04-21 00:28:24 +00:00
Avi Drissman
c91bd8ea79 Migrate to ExecJs/EvalJs in content/
Bug: 1157718
Change-Id: Ibb5bdb3f994630cc2b84f4e60adaf307fe646cb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2826401
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#874039}
2021-04-19 23:58:44 +00:00
Stephen Chenney
91a186b712 Prepare browser and ui tests for Paint Holding Cross Origin
The Paint Holding Cross Origin feature extends Paint Holding to most
navigations. Paint Holding defers the first commit of rendering
data from the main thread to the compositor until after First
Contentful Paint, or a 500ms timeout, has occurred.

From a test perspective, the most important change is related to input.
We drop all input when not updating the document lifecycle and while
deferring the commits. Many tests expect to navigate and then
immediately process input, and these tests timeout or otherwise fail
with Paint Holding.

This is a partial reland of
https://chromium-review.googlesource.com/c/chromium/src/+/2368282 with
just the various browser and ui test changes. Some switch setup
has been expanded from ChromeOS to all platforms, and some additional
tests now have changes. This is as a result of the original patch
generating failures on non trybot builders.

The goal is to make re-landing and future potential reverts less onerous.

Bug: 1120158
Change-Id: I97a7d7574ff3f33ad011682762c0b616f51c6d5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2773991
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#865581}
2021-03-23 10:42:01 +00:00
Owen Min
d58231043b Revert "Enable Paint Holding Cross Origin for tests"
This reverts commit 7aa2449e71.

Reason for revert: This may causes multiple flaky tests:

Windows:
https://ci.chromium.org/ui/p/chromium/builders/ci/Win%207%20Tests%20x64%20(1)/78657/overview
Linux:
https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20Ozone%20Tester%20(X11)/28133/overview

Original change's description:
> Enable Paint Holding Cross Origin for tests
>
> The Paint Holding Cross Origin feature extends Paint Holding to most
> navigations. Paint Holding defers the first commit of rendering
> data from the main thread to the compositor until after First
> Contentful Paint, or a 500ms timeout, has occurred.
>
> From a test perspective, the most important change is related to input.
> We drop all input when not updating the document lifecycle and while
> deferring the commits. Many tests expect to navigate and then immediately
> process input, and these tests timeout or otherwise fail with
> Paint Holding.
>
> Three strategies have been employed to address this:
> - For many tests it is sufficient to add text to the html content
>   so that First Contentful Paint is reached upon load and commits
>   begin. This works well for most cases but unfortunately the
>   linux_chromeos_rel bot is still flaky, probably due to slower loading.
> - Some tests just need to wait for hit test data, using
>   WaitForHitTestData
> - In other cases we allow early input using the blink flag.
>
> Test coverage for Paint Holding is provided by essentially all
> tests that use input or require a rendered result, so there is
> little concern about using the early input flag in a few test suites.
>
> This change may cause increased flakiness, particularly on the
> linux-chromeos-rel bot and Android. Please assign flakiness bugs
> to schenney@ and ping if necessary.
>
> Bug: 1120158
> Change-Id: Ief45735c5bdb4d48d6554dcfc12e3b621355e080
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368282
> Reviewed-by: Clemens Arbesser <arbesser@google.com>
> Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
> Reviewed-by: Evan Stade <estade@chromium.org>
> Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
> Reviewed-by: Bo <boliu@chromium.org>
> Reviewed-by: Owen Min <zmin@chromium.org>
> Reviewed-by: Eric Willigers <ericwilligers@chromium.org>
> Reviewed-by: Tommy Martino <tmartino@chromium.org>
> Commit-Queue: Stephen Chenney <schenney@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#864725}

Bug: 1120158
Change-Id: Ia1c24c7b2be34bf0a8f7a5ac72ecb692636d4c6b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2775893
Auto-Submit: Owen Min <zmin@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#864779}
2021-03-19 20:25:50 +00:00
Stephen Chenney
7aa2449e71 Enable Paint Holding Cross Origin for tests
The Paint Holding Cross Origin feature extends Paint Holding to most
navigations. Paint Holding defers the first commit of rendering
data from the main thread to the compositor until after First
Contentful Paint, or a 500ms timeout, has occurred.

From a test perspective, the most important change is related to input.
We drop all input when not updating the document lifecycle and while
deferring the commits. Many tests expect to navigate and then immediately
process input, and these tests timeout or otherwise fail with
Paint Holding.

Three strategies have been employed to address this:
- For many tests it is sufficient to add text to the html content
  so that First Contentful Paint is reached upon load and commits
  begin. This works well for most cases but unfortunately the
  linux_chromeos_rel bot is still flaky, probably due to slower loading.
- Some tests just need to wait for hit test data, using
  WaitForHitTestData
- In other cases we allow early input using the blink flag.

Test coverage for Paint Holding is provided by essentially all
tests that use input or require a rendered result, so there is
little concern about using the early input flag in a few test suites.

This change may cause increased flakiness, particularly on the
linux-chromeos-rel bot and Android. Please assign flakiness bugs
to schenney@ and ping if necessary.

Bug: 1120158
Change-Id: Ief45735c5bdb4d48d6554dcfc12e3b621355e080
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368282
Reviewed-by: Clemens Arbesser <arbesser@google.com>
Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: Owen Min <zmin@chromium.org>
Reviewed-by: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: Tommy Martino <tmartino@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#864725}
2021-03-19 18:33:40 +00:00
Lucas Furukawa Gadani
e764942951 Remove usages of WebContents::GetRenderViewHost().
This change should not have any change in behavior.

Bug: 1142671
Change-Id: I71a7ad1d1960541f488bc6d1b462a31630714192
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2648937
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Lucas Gadani <lfg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849925}
2021-02-03 03:04:32 +00:00
David Bokan
2b849704c1 Remove ForceLoadAtTop runtime flag
This Blink RuntimeEnabledFeature was previously used to enable this
opt-out for the TextFragment (and other kinds of load-time scrolls)
feature using an Origin-Trial.

The feature shipped for real as part of Document-Policy and the
Origin-Trial has been wound-down. This CL removes the no longer needed
RuntimeEnabledFeature.

Bug: 1047900
Change-Id: Ie8e8180aae6a9d76e4626eb2d5c8e4b3a9fb582c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622240
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Nick Burris <nburris@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843274}
2021-01-14 00:22:28 +00:00
Kevin McNee
777eef4ca5 Remove unnecessary references to RenderViewHost from input tests
Input largely operates in terms of RenderWidgetHosts which is what these
tests actually use. We remove some uses of RenderViewHost for clarity.

Bug: None
Change-Id: Ifd235d21379f0f69190125a93f1b23a2c2129fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485640
Reviewed-by: David Bokan <bokan@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Auto-Submit: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819020}
2020-10-20 18:53:49 +00:00
danakj
156a9bb548 Remove IsScrollOffsetAtTop from RenderWidgetHostView public API.
This method is just for tests, and they can find the value by using
a RenderFrameSubmissionObserver.

R=avi@chromium.org

Change-Id: Id73446e782953f8c4e94dad0c91cd37acd16b434
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390855
Commit-Queue: danakj <danakj@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: danakj <danakj@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804349}
2020-09-03 19:21:50 +00:00
David Bokan
71e8151d6e Enable text fragments across redirects
A text fragment occurs in a URL fragment and begins with ":~:text=...".
It is used to highlight and scroll the provided text into view when the
page is loaded. For user privacy reasons, we restrict scrolling the text
into view unless the navigation occurred via a user gesture. See:
https://github.com/WICG/scroll-to-text-fragment#security-considerations
for more details.

However, it is common (particularly on social and messaging services
where content is user-generated) for links to be served via a redirect.
A typical example (from chat.google.com) works like this:

 1. User receives and clicks a link to https://example.com#:~:text=foo"
 2. chat.google.com opens a new tab using window.open("", "_blank")
 3. chat.google.com calls document.write on the newly opened window to
   write a <meta> tag-based client redirect to
   google.com/url?url=https://example.com... which is the URL
   redirection service with the destination URL as a query param.
 4. google.com/url then calls window.location and writes
   "https://example.com#:~:text=foo" into it
 5. the new tab finally navigates to example.com

The only navigation that had a user gesture attached to it is the
initial empty document navigation in step 2. This means the example.com
page is navigated to without a user gesture and the text fragment is
blocked. A similar pattern is seen on many popular services: Twitter,
Instagram, Facebook Messenger, etc.

This CL solves the above scenario by introducing a "text fragment
token". This token grants its holder permission to invoke a text
fragment. The token can be used during load to invoke the text fragment,
or it can be passed into a navigation to grant permission to the next
page without requiring a user gesture. However, in either case, the
token is consumed so a page cannot both invoke a text fragment and pass
the token.

The token is created in only in DocumentLoader's constructor and while
processing a same-document navigation. For regular navigations, it is
only created if the current navigation was user initiated. For
same-document navigations, it's created only if browser-initiated and
the navigation has a text fragment. This mechanism can be thought of as
a user gesture that applies only to text fragment and whose lifetime
extends across navigations but cannot be copied and is always consumed
on use.

Bug: 1055455
Change-Id: Icddd849937d24b579bbeb5a4b9f87539d8339905
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159324
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799173}
2020-08-18 17:19:46 +00:00
David Bokan
84c9653658 Update force-load-at-top tests
Update tests for force-load-at-top DocumentPolicy to use updated false
syntax.

Bug: 1047900
Change-Id: I2b02b94715b0edd8dfaaf2676ff91dab01a00702
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354954
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798139}
2020-08-14 17:25:32 +00:00
Rakina Zata Amni
d3af5db993 Update non-navigation content/ tests to handle same-site BrowsingInstance swap
With crrev.com/c/2121522, some main-frame same-site navigations will
result in a new BrowsingInstance, SiteInstance, RenderFrameHost,
RenderView, etc. This CL updates expectations of tests under contents/
that didn't expect a change of RenderFrameHosts etc. on same-site main
frame navigations.

This CL does not include:
- Updates for navigation-related content_browsertests and
content_unittests, which are handled in crrev.com/c/2195872 and
crrev.com/c/2210035.
- Updates for tests under chrome/, components/ and layout tests (fixed
in other CLs)
- Fix to ensure order of unload handlers on same-site cross-RFH
navigations (will be fixed on a future CL)
- Fix to ensure WebPreferences are carried over for cross-RFH same-site
navigations (will be fixed on a future CL)

For more details, see doc: https://docs.google.com/document/d/1lHdkKLUe8H6ZP6ALwj-dsus7oYcuc93HkSCHCcerItg/edit?usp=sharing

Bug: 977562
Change-Id: I1fc507538b48d7566be28a4bd2ef83ff3cacd843
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210174
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Sreeja Kamishetty <sreejakshetty@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795365}
2020-08-06 06:51:39 +00:00
David Bokan
dd1b8d0ee3 [Text-Fragment] Fix ForceLoadAtTop anchor navigation
ForceLoadAtTop is a policy which pages can apply that blocks any kind of
scroll-on-load behavior including: fragments, text-fragments, history
scroll restoration.

However, we had a bug where by it blocked all fragment navigations,
including same page navigations (e.g. clicking a link that changes only
the fragment in the current URL). Since this isn't a new load, the
policy shouldn't apply in this case.

In addition to the small fix to this check, this CL also cleans up and
makes the scrolling to fragment condition more readable.

Bug: 1091247
Change-Id: Ic523b5b331720a822a5530698ab6560f580d2b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2265758
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Nick Burris <nburris@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782667}
2020-06-25 21:17:58 +00:00
Yash Khandelwal
9d70f389ca [TextUrlFragments] Add Tab key handling for Text fragment anchor
Tab key press will now use SetSequentialFocusNavigationStartingPoint to
put focus navigation to the start of selection.

Bug: 1075683
Test: TextFragmentAnchorBrowserTest.TabFocus added
Change-Id: I6611b75d142f6d38792387e8dfd9f41fed418544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2191336
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Nick Burris <nburris@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Commit-Queue: Yash Khandelwal <yakhande@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#770668}
2020-05-20 17:57:07 +00:00
Peter Kasting
919ce657e4 Add missing #includes of browser_test.h.
This is a step towards doing full IWYU of browser_test.h, which will
have other benefits.

Completely mechanical and already R+ed as part of r765923.

Tbr: sky
Bug: none
Change-Id: Icb7ab728098a6cf29c0920da4b524e96a7c024c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2186411
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766361}
2020-05-07 10:22:36 +00:00
Balazs Engedy
683d2c7a8f Revert "IWYU for browser_test.h."
This reverts commit 66a53c909a.

Reason for revert: Breaks compile on official branded builders.

Original change's description:
> IWYU for browser_test.h.
> 
> Include this directly in relevant test files.  This lets us convert the
> HAS_OUT_OF_PROC_TEST_RUNNER checks in this file and
> view_event_test_base.h into #errors, and force people to not even
> include this file in files that can't use it.
> 
> Bug: none
> Tbr: sky
> Change-Id: I86626099eb047eb53e8b3611de38ba6bebc01a0b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136117
> Commit-Queue: Peter Kasting <pkasting@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Lei Zhang <thestig@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#765923}

TBR=sky@chromium.org,pkasting@chromium.org,thestig@chromium.org

Change-Id: I4583916602404c310a93f571dd2c78645c6bd567
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: none
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2184132
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#765931}
2020-05-06 10:36:40 +00:00
Peter Kasting
66a53c909a IWYU for browser_test.h.
Include this directly in relevant test files.  This lets us convert the
HAS_OUT_OF_PROC_TEST_RUNNER checks in this file and
view_event_test_base.h into #errors, and force people to not even
include this file in files that can't use it.

Bug: none
Tbr: sky
Change-Id: I86626099eb047eb53e8b3611de38ba6bebc01a0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136117
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#765923}
2020-05-06 09:38:56 +00:00
David Bokan
3f72f10416 Separate text fragment browsertests
These have grown large enough that it makes sense to split them out from
navigation browser tests into their own separate file.

This CL is a straightforward move with not changes to the tests
themselves.

Bug: None
Change-Id: Iba4759b4e8f5797d5a693775684312c8997bac12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2160325
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762141}
2020-04-23 22:18:56 +00:00