bug 1549708: remote: implement Page.reload's ignoreCache argument; r=remote-protocol-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D50805

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2019-11-06 15:32:55 +00:00
parent 243b658475
commit 452bd6cbca
3 changed files with 46 additions and 2 deletions

View File

@ -14,6 +14,12 @@ const { UnsupportedError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
);
const {
LOAD_FLAGS_BYPASS_CACHE,
LOAD_FLAGS_BYPASS_PROXY,
LOAD_FLAGS_NONE,
} = Ci.nsIWebNavigation;
class Page extends ContentProcessDomain {
constructor(session) {
super(session);
@ -84,8 +90,13 @@ class Page extends ContentProcessDomain {
};
}
async reload() {
this.docShell.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
async reload({ ignoreCache }) {
let flags = LOAD_FLAGS_NONE;
if (ignoreCache) {
flags |= LOAD_FLAGS_BYPASS_CACHE;
flags |= LOAD_FLAGS_BYPASS_PROXY;
}
this.docShell.reload(flags);
}
getFrameTree() {

View File

@ -14,4 +14,5 @@ support-files =
[browser_javascriptDialog_confirm.js]
[browser_javascriptDialog_otherTarget.js]
[browser_javascriptDialog_prompt.js]
[browser_reload.js]
[browser_runtimeEvents.js]

View File

@ -0,0 +1,32 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function testReload({ Page }) {
await loadURL(toDataURL("halløj"));
info("Reloading document");
await Page.enable();
const loaded = Page.loadEventFired();
await Page.reload();
await loaded;
await ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
ok(!content.docShell.isForceReloading, "Document is not force-reloaded");
});
});
add_task(async function testReloadIgnoreCache({ Page }) {
await loadURL(toDataURL("halløj"));
info("Force-reloading document");
await Page.enable();
const loaded = Page.loadEventFired();
await Page.reload({ ignoreCache: true });
await loaded;
await ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
ok(content.docShell.isForceReloading, "Document is force-reloaded");
});
});