зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1708635) for causing dt failures in devtools/client/responsive/test/browser/browser_device_change. CLOSED TREE
Backed out changeset 6bce4e61777b (bug 1708635) Backed out changeset f15acee46be2 (bug 1708635)
This commit is contained in:
Родитель
ba9b6c6e39
Коммит
8dffb4667b
|
@ -59,8 +59,7 @@ const tests = [
|
|||
},
|
||||
{
|
||||
desc: "Reload the page.",
|
||||
setup: async ({ panel }) =>
|
||||
panel.accessibilityProxy.commands.targetCommand.reloadTopLevelTarget(),
|
||||
setup: async ({ panel }) => reload(panel.accessibilityProxy.currentTarget),
|
||||
expected: {
|
||||
tree: [
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
/* global waitUntilState, gBrowser */
|
||||
/* exported addTestTab, checkTreeState, checkSidebarState, checkAuditState, selectRow,
|
||||
toggleRow, toggleMenuItem, addA11yPanelTestsTask, navigate,
|
||||
toggleRow, toggleMenuItem, addA11yPanelTestsTask, reload, navigate,
|
||||
openSimulationMenu, toggleSimulationOption, TREE_FILTERS_MENU_ID,
|
||||
PREFS_MENU_ID */
|
||||
|
||||
|
@ -828,3 +828,13 @@ function addA11YPanelTask(msg, uri, task, options = {}) {
|
|||
await closeTabToolboxAccessibility(env.tab);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload panel target.
|
||||
* @param {Object} target Panel target.
|
||||
* @param {String} waitForTargetEvent Event to wait for after reload.
|
||||
*/
|
||||
function reload(target, waitForTargetEvent = "navigate") {
|
||||
executeSoon(() => target.reload());
|
||||
return once(target, waitForTargetEvent);
|
||||
}
|
||||
|
|
|
@ -291,6 +291,10 @@ function navigate(url) {
|
|||
return currentTarget().navigateTo({ url });
|
||||
}
|
||||
|
||||
function reload() {
|
||||
return currentTarget().reload();
|
||||
}
|
||||
|
||||
function getProperties(thread, grip) {
|
||||
const objClient = lookupThreadFront(thread).pauseGrip(grip);
|
||||
|
||||
|
@ -474,6 +478,7 @@ const clientCommands = {
|
|||
evaluateInFrame,
|
||||
evaluateExpressions,
|
||||
navigate,
|
||||
reload,
|
||||
getProperties,
|
||||
getFrameScopes,
|
||||
getFrames,
|
||||
|
|
|
@ -782,9 +782,7 @@ function deleteExpression(dbg, input) {
|
|||
*/
|
||||
async function reload(dbg, ...sources) {
|
||||
const navigated = waitForDispatch(dbg.store, "NAVIGATE");
|
||||
// We aren't waiting for reloadTopLevelTarget resolution
|
||||
// as the page may not load because of a breakpoint
|
||||
dbg.commands.targetCommand.reloadTopLevelTarget();
|
||||
await dbg.client.reload();
|
||||
await navigated;
|
||||
return waitForSources(dbg, ...sources);
|
||||
}
|
||||
|
|
|
@ -319,8 +319,7 @@ class DebugTargetInfo extends PureComponent {
|
|||
className: "qa-reload-button",
|
||||
icon: "chrome://browser/skin/reload.svg",
|
||||
l10nId: "toolbox.debugTargetInfo.reload",
|
||||
onClick: () =>
|
||||
this.props.toolbox.commands.targetCommand.reloadTopLevelTarget(),
|
||||
onClick: () => this.props.toolbox.target.reload(),
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -1090,7 +1090,7 @@ Toolbox.prototype = {
|
|||
].forEach(([id, force]) => {
|
||||
const key = L10N.getStr("toolbox." + id + ".key");
|
||||
this.shortcuts.on(key, event => {
|
||||
this.commands.targetCommand.reloadTopLevelTarget(force);
|
||||
this.reloadTarget(force);
|
||||
|
||||
// Prevent Firefox shortcuts from reloading the page
|
||||
event.preventDefault();
|
||||
|
@ -2930,6 +2930,13 @@ Toolbox.prototype = {
|
|||
event.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
* Tells the target tab to reload.
|
||||
*/
|
||||
reloadTarget: function(force) {
|
||||
this.target.reload({ options: { force } });
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads the tool next to the currently selected tool.
|
||||
*/
|
||||
|
|
|
@ -53,6 +53,25 @@ class BrowsingContextTargetFront extends TargetMixin(
|
|||
this.emit("frame-update", packet);
|
||||
}
|
||||
|
||||
async reload({ options } = {}) {
|
||||
try {
|
||||
await super.reload({ options });
|
||||
} catch (e) {
|
||||
dump(" reload exception: " + e + " >>> " + e.message + " <<<\n");
|
||||
// If the target follows the window global lifecycle, the reload request
|
||||
// will fail, and we should swallow the error. Re-throw it otherwise.
|
||||
// @backward-compat { version 88 } The trait check can be removed after
|
||||
// version 88 hits the release channel.
|
||||
const shouldSwallowReloadError =
|
||||
this.getTrait("supportsFollowWindowGlobalLifeCycleFlag") &&
|
||||
this.targetForm.followWindowGlobalLifeCycle;
|
||||
|
||||
if (!shouldSwallowReloadError) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for `tabNavigated` event.
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,14 @@ async function testToolboxInitialization(tab, inspector, toolbox) {
|
|||
await testMarkupView("#p", inspector);
|
||||
|
||||
info("Reloading the page.");
|
||||
await navigateTo(TEST_URI);
|
||||
const markuploaded = inspector.once("markuploaded");
|
||||
const onNewRoot = inspector.once("new-root");
|
||||
const onUpdated = inspector.once("inspector-updated");
|
||||
await toolbox.target.reload();
|
||||
info("Waiting for inspector to be ready.");
|
||||
await markuploaded;
|
||||
await onNewRoot;
|
||||
await onUpdated;
|
||||
|
||||
await selectNode("#q", inspector);
|
||||
await testMarkupView("#q", inspector);
|
||||
|
|
|
@ -54,7 +54,7 @@ var TEST_DATA = [
|
|||
];
|
||||
|
||||
add_task(async function() {
|
||||
const { inspector } = await openInspectorForURL(PAGE_1);
|
||||
const { inspector, toolbox } = await openInspectorForURL(PAGE_1);
|
||||
|
||||
for (const { url, nodeToSelect, selectedNode } of TEST_DATA) {
|
||||
if (nodeToSelect) {
|
||||
|
@ -62,7 +62,7 @@ add_task(async function() {
|
|||
await selectNode(nodeToSelect, inspector);
|
||||
}
|
||||
|
||||
await navigateTo(url);
|
||||
await navigateToAndWaitForNewRoot(url);
|
||||
|
||||
const nodeFront = await getNodeFront(selectedNode, inspector);
|
||||
ok(nodeFront, "Got expected node front");
|
||||
|
@ -72,4 +72,28 @@ add_task(async function() {
|
|||
selectedNode + " is selected after navigation."
|
||||
);
|
||||
}
|
||||
|
||||
async function navigateToAndWaitForNewRoot(url) {
|
||||
info("Navigating and waiting for new-root event after navigation.");
|
||||
|
||||
const current = await SpecialPowers.spawn(
|
||||
gBrowser.selectedBrowser,
|
||||
[],
|
||||
() => content.location.href
|
||||
);
|
||||
if (url == current) {
|
||||
info("Reloading page.");
|
||||
const markuploaded = inspector.once("markuploaded");
|
||||
const onNewRoot = inspector.once("new-root");
|
||||
const onUpdated = inspector.once("inspector-updated");
|
||||
|
||||
await toolbox.target.reload();
|
||||
info("Waiting for inspector to be ready.");
|
||||
await markuploaded;
|
||||
await onNewRoot;
|
||||
await onUpdated;
|
||||
} else {
|
||||
await navigateTo(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -460,17 +460,25 @@ class Connector {
|
|||
this.currentActivity = ACTIVITY_TYPE.NONE;
|
||||
};
|
||||
|
||||
// Waits for a series of "navigation start" and "navigation stop" events.
|
||||
const waitForNavigation = async () => {
|
||||
await this.currentTarget.once("will-navigate");
|
||||
await this.currentTarget.once("navigate");
|
||||
};
|
||||
|
||||
// Reconfigures the tab, optionally triggering a reload.
|
||||
const reconfigureTab = async options => {
|
||||
await this.commands.targetConfigurationCommand.updateConfiguration(
|
||||
const reconfigureTab = options => {
|
||||
return this.commands.targetConfigurationCommand.updateConfiguration(
|
||||
options
|
||||
);
|
||||
};
|
||||
|
||||
// Reconfigures the tab and waits for the target to finish navigating.
|
||||
const reconfigureTabAndReload = async options => {
|
||||
const navigationFinished = waitForNavigation();
|
||||
await reconfigureTab(options);
|
||||
await this.commands.targetCommand.reloadTopLevelTarget();
|
||||
await this.toolbox.target.reload();
|
||||
await navigationFinished;
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -199,8 +199,19 @@ registerCleanupFunction(() => {
|
|||
Services.cookies.removeAll();
|
||||
});
|
||||
|
||||
function waitForNavigation(target) {
|
||||
return new Promise(resolve => {
|
||||
target.once("will-navigate", () => {
|
||||
target.once("navigate", () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleCache(toolbox, disabled) {
|
||||
const options = { cacheDisabled: disabled };
|
||||
const navigationFinished = waitForNavigation(toolbox.target);
|
||||
|
||||
// Disable the cache for any toolbox that it is opened from this point on.
|
||||
Services.prefs.setBoolPref("devtools.cache.disabled", disabled);
|
||||
|
@ -208,7 +219,9 @@ async function toggleCache(toolbox, disabled) {
|
|||
await toolbox.commands.targetConfigurationCommand.updateConfiguration(
|
||||
options
|
||||
);
|
||||
await toolbox.commands.targetCommand.reloadTopLevelTarget();
|
||||
await toolbox.target.reload();
|
||||
|
||||
await navigationFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ const {
|
|||
} = require("devtools/client/performance/test/helpers/wait-utils");
|
||||
|
||||
add_task(async function() {
|
||||
const { panel } = await initPerformanceInNewTab({
|
||||
const { panel, target } = await initPerformanceInNewTab({
|
||||
url: SIMPLE_URL,
|
||||
win: window,
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ add_task(async function() {
|
|||
const { PerformanceController } = panel.panelWin;
|
||||
|
||||
await startRecording(panel);
|
||||
await reload(panel);
|
||||
await reload(target);
|
||||
|
||||
await waitUntil(() => {
|
||||
// Wait until we get the necessary markers.
|
||||
|
|
|
@ -21,7 +21,7 @@ const {
|
|||
} = require("devtools/client/performance/test/helpers/wait-utils");
|
||||
|
||||
add_task(async function() {
|
||||
const { panel } = await initPerformanceInNewTab({
|
||||
const { panel, target } = await initPerformanceInNewTab({
|
||||
url: SIMPLE_URL,
|
||||
win: window,
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ add_task(async function() {
|
|||
const { PerformanceController } = panel.panelWin;
|
||||
|
||||
await startRecording(panel);
|
||||
await reload(panel);
|
||||
await reload(target);
|
||||
|
||||
const recording = PerformanceController.getCurrentRecording();
|
||||
const markersLength = recording.getAllData().markers.length;
|
||||
|
|
|
@ -160,8 +160,9 @@ exports.waitForOverviewRenderedWithMarkers = (
|
|||
};
|
||||
|
||||
/**
|
||||
* Reloads the current tab
|
||||
* Reloads the given tab target.
|
||||
*/
|
||||
exports.reload = async panel => {
|
||||
await panel.commands.targetCommand.reloadTopLevelTarget();
|
||||
exports.reload = target => {
|
||||
target.reload();
|
||||
return once(target, "navigate");
|
||||
};
|
||||
|
|
|
@ -259,6 +259,8 @@ class ResponsiveUI {
|
|||
const isTabContentDestroying =
|
||||
isWindowClosing || options?.reason === "TabClose";
|
||||
|
||||
let currentTarget;
|
||||
|
||||
// Ensure init has finished before starting destroy
|
||||
if (!isTabContentDestroying) {
|
||||
await this.inited;
|
||||
|
@ -271,6 +273,10 @@ class ResponsiveUI {
|
|||
// Hide browser UI to avoid displaying weird intermediate states while closing.
|
||||
this.hideBrowserUI();
|
||||
|
||||
// Save reference to tab target before RDM stops listening to it. Will need it if
|
||||
// the tab has to be reloaded to remove the emulated settings created by RDM.
|
||||
currentTarget = this.currentTarget;
|
||||
|
||||
// Resseting the throtting needs to be done before the
|
||||
// network events watching is stopped.
|
||||
await this.updateNetworkThrottling();
|
||||
|
@ -310,8 +316,8 @@ class ResponsiveUI {
|
|||
reloadNeeded |=
|
||||
(await this.updateTouchSimulation()) &&
|
||||
this.reloadOnChange("touchSimulation");
|
||||
if (reloadNeeded) {
|
||||
await this.reloadBrowser();
|
||||
if (reloadNeeded && currentTarget) {
|
||||
await currentTarget.reload();
|
||||
}
|
||||
|
||||
// Unwatch targets & resources as the last step. If we are not waching for
|
||||
|
@ -1052,7 +1058,7 @@ class ResponsiveUI {
|
|||
* Reload the current tab.
|
||||
*/
|
||||
async reloadBrowser() {
|
||||
await this.commands.targetCommand.reloadTopLevelTarget();
|
||||
await this.currentTarget.reload();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,13 +42,10 @@ class TargetCommand extends EventEmitter {
|
|||
*
|
||||
* @param {DescriptorFront} descriptorFront
|
||||
* The context to inspector identified by this descriptor.
|
||||
* @param {Object} commands
|
||||
* The commands object with all interfaces defined from devtools/shared/commands/
|
||||
*/
|
||||
constructor({ descriptorFront, commands }) {
|
||||
constructor({ descriptorFront }) {
|
||||
super();
|
||||
|
||||
this.commands = commands;
|
||||
this.descriptorFront = descriptorFront;
|
||||
this.rootFront = descriptorFront.client.mainRoot;
|
||||
|
||||
|
@ -659,64 +656,6 @@ class TargetCommand extends EventEmitter {
|
|||
this.switchToTarget(newTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the current top level target.
|
||||
* This only works for targets inheriting from BrowsingContextTarget.
|
||||
*
|
||||
* @param {Boolean} bypassCache
|
||||
* If true, the reload will be forced to bypass any cache.
|
||||
*/
|
||||
async reloadTopLevelTarget(bypassCache = false) {
|
||||
if (!this.targetFront.isBrowsingContext) {
|
||||
throw new Error(
|
||||
"The top level target isn't a BrowsingContext and don't support being reloaded"
|
||||
);
|
||||
}
|
||||
|
||||
// Wait for the next DOCUMENT_EVENT's dom-complete event
|
||||
let resolve = null;
|
||||
const onReloaded = new Promise(r => (resolve = r));
|
||||
const { resourceCommand } = this.commands;
|
||||
const { DOCUMENT_EVENT } = resourceCommand.TYPES;
|
||||
const onAvailable = resources => {
|
||||
if (resources.find(resource => resource.name == "dom-complete")) {
|
||||
resourceCommand.unwatchResources([DOCUMENT_EVENT], { onAvailable });
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
// Wait for watchResources completion before reloading, otherwise we might miss the dom-complete event
|
||||
// if watchResources is still pending while the reload already started and finished loading the document early.
|
||||
await resourceCommand.watchResources([DOCUMENT_EVENT], {
|
||||
onAvailable,
|
||||
ignoreExistingResources: true,
|
||||
});
|
||||
|
||||
const { targetFront } = this;
|
||||
try {
|
||||
// Arguments of reload are a bit convoluted.
|
||||
// We expect an dictionary object, which only support one attribute
|
||||
// called "force" which force bypassing the caches.
|
||||
await targetFront.reload({ options: { force: bypassCache } });
|
||||
} catch (e) {
|
||||
dump(" target reload exception: " + e + " >>> " + e.message + " <<<\n");
|
||||
// If the target follows the window global lifecycle, the reload request
|
||||
// will fail, and we should swallow the error. Re-throw it otherwise.
|
||||
// Reload request will fail because the target actor is going to be destroyed
|
||||
// during the reload and so the ongoing reload request will most likely fail in some way.
|
||||
// @backward-compat { version 88 } The trait check can be removed after
|
||||
// version 88 hits the release channel.
|
||||
const shouldSwallowReloadError =
|
||||
targetFront.getTrait("supportsFollowWindowGlobalLifeCycleFlag") &&
|
||||
targetFront.targetForm.followWindowGlobalLifeCycle;
|
||||
|
||||
if (!shouldSwallowReloadError) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
await onReloaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the top level target is replaced by a new one.
|
||||
* Typically when we navigate to another domain which requires to be loaded in a distinct process.
|
||||
|
|
|
@ -7,7 +7,6 @@ support-files =
|
|||
!/devtools/client/shared/test/test-actor.js
|
||||
head.js
|
||||
simple_document.html
|
||||
incremental-js-value-script.sjs
|
||||
fission_document.html
|
||||
fission_iframe.html
|
||||
test_service_worker.js
|
||||
|
@ -19,7 +18,6 @@ support-files =
|
|||
[browser_target_list_browser_workers.js]
|
||||
[browser_target_list_frames.js]
|
||||
[browser_target_list_getAllTargets.js]
|
||||
[browser_target_command_reload.js]
|
||||
[browser_target_list_preffedoff.js]
|
||||
[browser_target_list_processes.js]
|
||||
[browser_target_list_service_workers.js]
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test the TargetCommand's reload method
|
||||
//
|
||||
// Note that we reload against main process,
|
||||
// but this is hard/impossible to test as it reloads the test script itself
|
||||
// and so stops its execution.
|
||||
|
||||
// Load a page with a JS script that change its value everytime we load it
|
||||
// (that's to see if the reload loads from cache or not)
|
||||
const TEST_URL = URL_ROOT + "incremental-js-value-script.sjs";
|
||||
|
||||
add_task(async function() {
|
||||
info(" ### Test reloading a Tab");
|
||||
|
||||
// Create a TargetCommand for a given test tab
|
||||
const tab = await addTab(TEST_URL);
|
||||
const commands = await CommandsFactory.forTab(tab);
|
||||
const targetCommand = commands.targetCommand;
|
||||
|
||||
// We have to start listening in order to ensure having a targetFront available
|
||||
await targetCommand.startListening();
|
||||
|
||||
const firstJSValue = await getContentVariable();
|
||||
is(firstJSValue, "1", "Got an initial value for the JS variable");
|
||||
|
||||
const onReloaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
await targetCommand.reloadTopLevelTarget();
|
||||
info("Wait for the tab to be reloaded");
|
||||
await onReloaded;
|
||||
|
||||
const secondJSValue = await getContentVariable();
|
||||
is(
|
||||
secondJSValue,
|
||||
"1",
|
||||
"The first reload didn't bypass the cache, so the JS Script is the same and we got the same value"
|
||||
);
|
||||
|
||||
const onSecondReloaded = BrowserTestUtils.browserLoaded(
|
||||
gBrowser.selectedBrowser
|
||||
);
|
||||
await targetCommand.reloadTopLevelTarget(true);
|
||||
info("Wait for the tab to be reloaded");
|
||||
await onSecondReloaded;
|
||||
|
||||
// The value is 3 and not 2, because we got a HTTP request, but it returned 304 and the browser fetched his cached content
|
||||
const thirdJSValue = await getContentVariable();
|
||||
is(
|
||||
thirdJSValue,
|
||||
"3",
|
||||
"The second reload did bypass the cache, so the JS Script is different and we got a new value"
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
|
||||
await commands.destroy();
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info(" ### Test reloading a content process");
|
||||
|
||||
const tab = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
url: "data:text/html,foo",
|
||||
forceNewProcess: true,
|
||||
});
|
||||
|
||||
const { osPid } = tab.linkedBrowser.browsingContext.currentWindowGlobal;
|
||||
|
||||
const commands = await CommandsFactory.forProcess(osPid);
|
||||
|
||||
// We have to start listening in order to ensure having a targetFront available
|
||||
await commands.targetCommand.startListening();
|
||||
|
||||
try {
|
||||
await commands.targetCommand.reloadTopLevelTarget();
|
||||
ok(false, "reloadToLevelTarget() should have thrown for the main process");
|
||||
} catch (e) {
|
||||
is(
|
||||
e.message,
|
||||
"The top level target isn't a BrowsingContext and don't support being reloaded"
|
||||
);
|
||||
}
|
||||
await commands.destroy();
|
||||
});
|
||||
|
||||
function getContentVariable() {
|
||||
return SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
|
||||
return content.wrappedJSObject.jsValue;
|
||||
});
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
function handleRequest(request, response) {
|
||||
let Etag = '"4d881ab-b03-435f0a0f9ef00"';
|
||||
let IfNoneMatch = request.hasHeader("If-None-Match")
|
||||
? request.getHeader("If-None-Match")
|
||||
: "";
|
||||
|
||||
var counter = getState("cache-counter") || 1;
|
||||
let page = "<script>var jsValue = '" + counter + "';</script>" + counter;
|
||||
|
||||
setState("cache-counter", "" + (parseInt(counter) + 1));
|
||||
|
||||
response.setHeader("Etag", Etag, false);
|
||||
|
||||
if (IfNoneMatch === Etag) {
|
||||
response.setStatusLine(request.httpVersion, "304", "Not Modified");
|
||||
} else {
|
||||
response.setHeader("Content-Type", "text/html; charset=utf-8", false);
|
||||
response.setHeader("Content-Length", page.length + "", false);
|
||||
response.write(page);
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче