summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addHTML.window.js20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addIframe.window.js40
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addScripts.window.js19
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-defaults.window.js15
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-extra-config.window.js36
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-features.window.js23
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-invalid-origin.window.js21
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-startOn.window.js19
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-target.window.js17
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWorker.window.js29
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/constructor.window.js38
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/createContext-bad-executorCreator.window.js20
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigateToNew.window.js37
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-bfcache.window.js35
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-helpers.window.js28
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-same-document.window.js39
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js48
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script.js3
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script2.js3
19 files changed, 490 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addHTML.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addHTML.window.js
new file mode 100644
index 0000000000..0c093cc462
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addHTML.window.js
@@ -0,0 +1,20 @@
+// META: title=RemoteContextWrapper addHtml
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+
+ const main = await rcHelper.addWindow();
+ await assertSimplestScriptRuns(main);
+
+ await main.addHTML('<div id=div-id>div-content</div>');
+ await assertFunctionRuns(
+ main, () => document.getElementById('div-id').textContent, 'div-content');
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addIframe.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addIframe.window.js
new file mode 100644
index 0000000000..c1630e4680
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addIframe.window.js
@@ -0,0 +1,40 @@
+// META: title=RemoteContextWrapper addIframe
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ // Precondition: Test was loaded from the HTTP_ORIGIN.
+ assert_equals(
+ location.origin, get_host_info()['HTTP_ORIGIN'],
+ 'test window was loaded on HTTP_ORIGIN');
+
+ const rcHelper = new RemoteContextHelper();
+
+ const main = await rcHelper.addWindow();
+
+ const headerName = 'x-wpt-test-header';
+ const headerValue = 'test-escaping()';
+ const iframe = await main.addIframe(
+ /*extraConfig=*/ {
+ origin: 'HTTP_REMOTE_ORIGIN',
+ scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'],
+ headers: [[headerName, headerValue]],
+ },
+ /*attributes=*/ {id: 'test-id'},
+ );
+
+ await assertSimplestScriptRuns(iframe);
+ await assertFunctionRuns(iframe, () => testFunction(), 'testFunction exists');
+ await assertOriginIsAsExpected(iframe, get_host_info()['HTTP_REMOTE_ORIGIN']);
+ await assertHeaderIsAsExpected(iframe, headerName, headerValue);
+
+ assert_equals(
+ await main.executeScript(() => document.getElementById('test-id').id),
+ 'test-id', 'verify id');
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addScripts.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addScripts.window.js
new file mode 100644
index 0000000000..01cf06c65d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addScripts.window.js
@@ -0,0 +1,19 @@
+// META: title=RemoteContextWrapper addScripts
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+
+ const main = await rcHelper.addWindow();
+ await assertSimplestScriptRuns(main);
+
+ await main.addScripts(['./resources/test-script.js']);
+ await assertFunctionRuns(main, () => testFunction(), 'testFunction exists');
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-defaults.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-defaults.window.js
new file mode 100644
index 0000000000..34fa9cd39a
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-defaults.window.js
@@ -0,0 +1,15 @@
+// META: title=RemoteContextHelper with defaults
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+ const main = await rcHelper.addWindow();
+ await assertSimplestScriptRuns(main);
+ await assertOriginIsAsExpected(main, location.origin);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-extra-config.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-extra-config.window.js
new file mode 100644
index 0000000000..112d2d726e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-extra-config.window.js
@@ -0,0 +1,36 @@
+// META: title=RemoteContextHelper addWindow with extra config
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ const header1Name = 'x-wpt-test-header1';
+ const header1Value = 'test-escaping1()';
+ const rcHelper = new RemoteContextHelper({
+ origin: 'HTTP_REMOTE_ORIGIN',
+ scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'],
+ headers: [[header1Name, header1Value]],
+ });
+
+ const header2Name = 'x-wpt-test-header2';
+ const header2Value = 'test-escaping2()';
+ const main = await rcHelper.addWindow(
+ {
+ origin: location.origin,
+ scripts: [new URL('./resources/test-script2.js', location).toString()],
+ headers: [[header2Name, header2Value]],
+ },
+ );
+
+ await assertSimplestScriptRuns(main);
+ await assertFunctionRuns(main, () => testFunction(), 'testFunction exists');
+ await assertFunctionRuns(main, () => testFunction2(), 'testFunction2 exists');
+ await assertOriginIsAsExpected(main, location.origin);
+ await assertHeaderIsAsExpected(main, header1Name, header1Value);
+ await assertHeaderIsAsExpected(main, header2Name, header2Value);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-features.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-features.window.js
new file mode 100644
index 0000000000..329c55e626
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-features.window.js
@@ -0,0 +1,23 @@
+// META: title=RemoteContextHelper addWindow features
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+ {
+ const main = await rcHelper.addWindow();
+ await assertSimplestScriptRuns(main);
+ await assertWindowHasOpenerEquals(main, true);
+ }
+ {
+ const main = await rcHelper.addWindow(
+ /*extraConfig=*/ null, /*options=*/ {features: 'noopener'});
+ await assertSimplestScriptRuns(main);
+ await assertWindowHasOpenerEquals(main, false);
+ }
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-invalid-origin.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-invalid-origin.window.js
new file mode 100644
index 0000000000..58aee312cc
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-invalid-origin.window.js
@@ -0,0 +1,21 @@
+// META: title=RemoteContextHelper addWindow with extra config
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ const header1Name = 'x-wpt-test-header1';
+ const header1Value = 'test-escaping1()';
+ const rcHelper = new RemoteContextHelper({
+ origin: 'INVALID',
+ });
+
+ promise_rejects_js(
+ t, RangeError, rcHelper.addWindow(),
+ 'Exception should be thrown for invalid origin.');
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-startOn.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-startOn.window.js
new file mode 100644
index 0000000000..0f57a87638
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-startOn.window.js
@@ -0,0 +1,19 @@
+// META: title=RemoteContextHelper addWindow target
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+ const main = await rcHelper.addWindow({startOn: 'pageshow'});
+ await assertSimplestScriptRuns(main);
+ await assert_equals(
+ await main.executeScript(() => {
+ return executorStartEvent.type;
+ }),
+ 'pageshow');
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-target.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-target.window.js
new file mode 100644
index 0000000000..3f742048b4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWindow-target.window.js
@@ -0,0 +1,17 @@
+// META: title=RemoteContextHelper addWindow target
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+ const name = 'a name';
+ const main = await rcHelper.addWindow(
+ /*extraConfig=*/ null, /*options=*/ {target: name});
+ await assertSimplestScriptRuns(main);
+ await assertWindowNameEquals(main, name);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWorker.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWorker.window.js
new file mode 100644
index 0000000000..d4ba8b0312
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/addWorker.window.js
@@ -0,0 +1,29 @@
+// META: title=RemoteContextWrapper addWorker
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+
+ const main = await rcHelper.addWindow();
+
+ const headerName = 'x-wpt-test-header';
+ const headerValue = 'test-escaping()';
+ const worker = await main.addWorker(
+ {
+ scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'],
+ headers: [[headerName, headerValue]],
+ },
+ );
+
+ await assertSimplestScriptRuns(worker);
+ await assertFunctionRuns(worker, () => testFunction(), 'testFunction exists');
+ await assertOriginIsAsExpected(worker, location.origin);
+ await assertHeaderIsAsExpected(worker, headerName, headerValue);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/constructor.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/constructor.window.js
new file mode 100644
index 0000000000..dcbb3dabbc
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/constructor.window.js
@@ -0,0 +1,38 @@
+// META: title=RemoteContextHelper constructor
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+// This tests that arguments passed to the constructor are respected.
+promise_test(async t => {
+ // Precondition: Test was loaded from the HTTP_ORIGIN.
+ assert_equals(
+ location.origin, get_host_info()['HTTP_ORIGIN'],
+ 'test window was loaded on HTTP_ORIGIN');
+
+ const headerName = 'x-wpt-test-header';
+ const headerValue = 'test-escaping()';
+ const rcHelper = new RemoteContextHelper({
+ origin: 'HTTP_REMOTE_ORIGIN',
+ scripts: [
+ '/common/get-host-info.sub.js',
+ './resources/test-script.js',
+ ],
+ headers: [[headerName, headerValue]],
+ });
+
+
+ const main = await rcHelper.addWindow();
+
+ await assertSimplestScriptRuns(main);
+ await assertFunctionRuns(main, () => testFunction(), 'testFunction exists');
+
+ // Verify that the origin is different.
+ await assertOriginIsAsExpected(main, get_host_info()['HTTP_REMOTE_ORIGIN']);
+
+ await assertHeaderIsAsExpected(main, headerName, headerValue);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/createContext-bad-executorCreator.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/createContext-bad-executorCreator.window.js
new file mode 100644
index 0000000000..bf24581173
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/createContext-bad-executorCreator.window.js
@@ -0,0 +1,20 @@
+// META: title=RemoteContextHelper createContext with throwing/rejecting executorCreators.
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+
+ const err = new Error('something bad!');
+ promise_rejects_exactly(
+ t, err, rcHelper.createContext({ executorCreator() { throw err; } }),
+ 'Sync exception must be rethrown');
+
+ promise_rejects_exactly(
+ t, err, rcHelper.createContext({ executorCreator() { return Promise.reject(err); } }),
+ 'Async rejection must be rethrown');
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigateToNew.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigateToNew.window.js
new file mode 100644
index 0000000000..f7dd3f8325
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigateToNew.window.js
@@ -0,0 +1,37 @@
+// META: title=RemoteContextWrapper navigateToNew
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ // Precondition: Test was loaded from the HTTP_ORIGIN.
+ assert_equals(
+ location.origin, get_host_info()['HTTP_ORIGIN'],
+ 'test window was loaded on HTTP_ORIGIN');
+
+ const rcHelper = new RemoteContextHelper();
+
+ const main = await rcHelper.addWindow();
+
+ const headerName = 'x-wpt-test-header';
+ const headerValue = 'test-escaping()';
+ const newMain = await main.navigateToNew(
+ {
+ origin: 'HTTP_REMOTE_ORIGIN',
+ scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'],
+ headers: [[headerName, headerValue]],
+ },
+ );
+
+ await assertSimplestScriptRuns(newMain);
+ await assertFunctionRuns(
+ newMain, () => testFunction(), 'testFunction exists');
+
+ const remoteOrigin = get_host_info()['HTTP_REMOTE_ORIGIN'];
+ await assertOriginIsAsExpected(newMain, remoteOrigin);
+ await assertHeaderIsAsExpected(newMain, headerName, headerValue);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-bfcache.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-bfcache.window.js
new file mode 100644
index 0000000000..1fa90a9064
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-bfcache.window.js
@@ -0,0 +1,35 @@
+// META: title=RemoteContextHelper navigation using BFCache
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+
+ // Open a window with noopener so that BFCache will work.
+ const rc1 = await rcHelper.addWindow(
+ /*config=*/ null, /*options=*/ {features: 'noopener'});
+
+ // Add a pageshow listener to stash the event.
+ await rc1.executeScript(() => {
+ window.addEventListener('pageshow', (event) => {
+ window.pageshowEvent = event;
+ });
+ });
+
+ // Navigate away.
+ const rc2 = await rc1.navigateToNew();
+ await assertSimplestScriptRuns(rc2);
+
+ // Navigate back.
+ await rc2.historyBack();
+
+ // Verify that the document was BFCached.
+ assert_true(await rc1.executeScript(() => {
+ return window.pageshowEvent.persisted;
+ }));
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-helpers.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-helpers.window.js
new file mode 100644
index 0000000000..079e20661e
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-helpers.window.js
@@ -0,0 +1,28 @@
+// META: title=RemoteContextHelper navigation helpers
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+// META: timeout=long
+
+'use strict';
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+ const rc1 = await rcHelper.addWindow();
+ await assertSimplestScriptRuns(rc1);
+
+ const rc2 = await rc1.navigateToNew();
+ await assertSimplestScriptRuns(rc2);
+
+ await rc2.historyBack();
+ await assertSimplestScriptRuns(rc1);
+
+ await rc1.historyForward();
+ await assertSimplestScriptRuns(rc2);
+
+ const rc3 = await rc2.navigateToNew();
+ await rc3.historyGo(-2);
+ await assertSimplestScriptRuns(rc1);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-same-document.window.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-same-document.window.js
new file mode 100644
index 0000000000..6f637e2b90
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/navigation-same-document.window.js
@@ -0,0 +1,39 @@
+// META: title=RemoteContextHelper navigation using BFCache
+// META: script=/common/dispatcher/dispatcher.js
+// META: script=/common/get-host-info.sub.js
+// META: script=/common/utils.js
+// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js
+// META: script=./resources/test-helper.js
+
+'use strict';
+
+async function assertLocationIs(remoteContextWrapper, expectedLocation) {
+ assert_equals(
+ await remoteContextWrapper.executeScript(() => {
+ return location.toString();
+ }),
+ expectedLocation, 'verify location');
+}
+
+promise_test(async t => {
+ const rcHelper = new RemoteContextHelper();
+
+ const rc = await rcHelper.addWindow();
+
+ const oldLocation = await rc.executeScript(() => {
+ return location.toString();
+ });
+ const newLocation = oldLocation + '#fragment';
+
+ // Navigate to same document.
+ await rc.navigateTo(newLocation);
+
+ // Verify that the window navigated.
+ await assertLocationIs(rc, newLocation);
+
+ // Navigate back.
+ await rc.historyBack(oldLocation);
+
+ // Verify that the window navigated back and the executor is running.
+ await assertLocationIs(rc, oldLocation);
+});
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js
new file mode 100644
index 0000000000..71cd87e553
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js
@@ -0,0 +1,48 @@
+async function assertSimplestScriptRuns(remoteContextWrapper) {
+ assert_equals(
+ await remoteContextWrapper.executeScript(() => {
+ return 1;
+ }),
+ 1, 'simplest script runs');
+}
+
+async function assertFunctionRuns(
+ remoteContextWrapper, functionToRun, expectedReturn) {
+ assert_equals(
+ await remoteContextWrapper.executeScript(functionToRun), expectedReturn,
+ 'function runs');
+}
+
+async function assertOriginIsAsExpected(remoteContextWrapper, expectedOrigin) {
+ assert_equals(
+ await remoteContextWrapper.executeScript(() => {
+ return location.origin;
+ }),
+ expectedOrigin, 'verify origin');
+}
+
+async function assertWindowNameEquals(remoteContextWrapper, expectedName) {
+ assert_equals(
+ await remoteContextWrapper.executeScript(() => {
+ return window.name;
+ }),
+ expectedName, 'verify name');
+}
+
+async function assertWindowHasOpenerEquals(remoteContextWrapper, hasParent) {
+ assert_equals(
+ await remoteContextWrapper.executeScript(() => {
+ return !!window.opener;
+ }),
+ hasParent, 'verify opener');
+}
+
+async function assertHeaderIsAsExpected(
+ remoteContextWrapper, headerName, headerValue) {
+ assert_equals(
+ headerValue,
+ await remoteContextWrapper.executeScript(async (headerName) => {
+ const res = await fetch(location);
+ return res.headers.get(headerName);
+ }, [headerName]), 'header is set');
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script.js
new file mode 100644
index 0000000000..d1c02cab29
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script.js
@@ -0,0 +1,3 @@
+function testFunction() {
+ return 'testFunction exists';
+}
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script2.js b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script2.js
new file mode 100644
index 0000000000..f9e72c442b
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-script2.js
@@ -0,0 +1,3 @@
+function testFunction2() {
+ return 'testFunction2 exists';
+}