Skip to content

Commit

Permalink
[mparch] Use NavigationController thru a frame tree for navigation co…
Browse files Browse the repository at this point in the history
…mmands

This CL uses NavigationController thru a frame tree for
Page.GetNavigationHistory(), Page.NavigateToHistoryEntry(), and
Page.ResetNavigationHistory().

These commands check if the frame is a top level since they are for a
history. If they are called from inner frames such as subframes or
fenced frames, they return an error.

Bug: 1324905, 1170273
Change-Id: Iccea6eeaac5b797bd3082f425e81083b13107064
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3671274
Reviewed-by: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1010449}
NOKEYCHECK=True
GitOrigin-RevId: 9a07385b5cdd4ff9f42c8d915d014ce7adf3cbc3
  • Loading branch information
jkim-julie authored and copybara-github committed Jun 3, 2022
1 parent 32722e4 commit fa14c8b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(async function(testRunner) {
const {session, dp} = await testRunner.startURL(
'resources/page-with-fenced-frame.php',
'Tests that Page.GetNavigationHistory(), ' +
'Page.NavigateToHistoryEntry(), and Page.ResetNavigationHistory() ' +
'in a fenced frame are not allowed.');
await dp.Page.enable();
await dp.Runtime.enable();

dp.Target.setAutoAttach(
{autoAttach: true, waitForDebuggerOnStart: false, flatten: true});
let {sessionId} = (await dp.Target.onceAttachedToTarget()).params;

let childSession = session.createChild(sessionId);
let ffdp = childSession.protocol;

// Wait for FF to finish loading.
await ffdp.Page.enable();
ffdp.Page.setLifecycleEventsEnabled({enabled: true});
await ffdp.Page.onceLifecycleEvent(event => event.params.name === 'load');

await ffdp.page.navigate(
'http://localhost:8000/inspector-protocol/bfcache/resources/page-with-embed.html');

const result =
await childSession.sendCommand('Page.getNavigationHistory', {});
testRunner.log(
'Page.getNavigationHistory() from a fenced frame:\n' +
(result.error ? 'PASS: ' + result.error.message : 'FAIL: no error'));

await ffdp.Page.navigateToHistoryEntry({});
testRunner.log(
'Page.navigateToHistoryEntry() from a fenced frame:\n' +
(result.error ? 'PASS: ' + result.error.message : 'FAIL: no error'));

await ffdp.Page.ResetNavigationHistory({});
testRunner.log(
'Page.ResetNavigationHistory() from a fenced frame:\n' +
(result.error ? 'PASS: ' + result.error.message : 'FAIL: no error'));

testRunner.completeTest();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Tests that Page.GetNavigationHistory(), Page.NavigateToHistoryEntry(), and Page.ResetNavigationHistory() in a fenced frame are not allowed.
Page.getNavigationHistory() from a fenced frame:
PASS: Command can only be executed on top-level targets
Page.navigateToHistoryEntry() from a fenced frame:
PASS: Command can only be executed on top-level targets
Page.ResetNavigationHistory() from a fenced frame:
PASS: Command can only be executed on top-level targets

0 comments on commit fa14c8b

Please sign in to comment.