Backed out changeset 3c239920e8fb (bug 1636924) for perma failures on browser_ext_devtools_inspectedWindow.js CLOSED TREE

This commit is contained in:
Razvan Maries 2020-05-15 15:33:15 +03:00
Родитель b10845210b
Коммит f5f48cab39
29 изменённых файлов: 207 добавлений и 157 удалений

Просмотреть файл

@ -307,8 +307,8 @@ class AccessibilityProxy {
: this.accessibilityEventsMap;
}
async _onTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async _onTargetAvailable({ targetFront, isTopLevel }) {
if (isTopLevel) {
await this._updateTarget(targetFront);
}
}

Просмотреть файл

@ -162,8 +162,8 @@ AccessibilityPanel.prototype = {
this._opening.then(() => this.refresh());
},
async onTargetAvailable({ targetFront, isTargetSwitching }) {
if (targetFront.isTopLevel) {
async onTargetAvailable({ targetFront, isTopLevel, isTargetSwitching }) {
if (isTopLevel) {
await this.accessibilityProxy.initializeProxyForPanel(targetFront);
this.accessibilityProxy.currentTarget.on("navigate", this.onTabNavigated);
}

Просмотреть файл

@ -126,16 +126,16 @@ window.Application = {
targetFront.off("navigate", this.handleOnNavigate);
},
onTargetAvailable({ targetFront }) {
if (!targetFront.isTopLevel) {
onTargetAvailable({ targetFront, isTopLevel }) {
if (!isTopLevel) {
return; // ignore target frames that are not top level for now
}
this.setupTarget(targetFront);
},
onTargetDestroyed({ targetFront }) {
if (!targetFront.isTopLevel) {
onTargetDestroyed({ targetFront, isTopLevel }) {
if (!isTopLevel) {
return; // ignore target frames that are not top level for now
}

Просмотреть файл

@ -33,9 +33,10 @@ export async function onConnect(
async function onTargetAvailable({
targetFront,
isTopLevel,
isTargetSwitching,
}): Promise<void> {
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}
@ -90,8 +91,8 @@ async function onTargetAvailable({
await clientCommands.checkIfAlreadyPaused();
}
function onTargetDestroyed({ targetFront }): void {
if (targetFront.isTopLevel) {
function onTargetDestroyed({ targetFront, isTopLevel }): void {
if (isTopLevel) {
targetFront.off("will-navigate", actions.willNavigate);
targetFront.off("navigate", actions.navigated);
removeEventsTopTarget(targetFront);

Просмотреть файл

@ -130,9 +130,9 @@ DomPanel.prototype = {
this.refresh();
},
onTargetAvailable: function({ targetFront }) {
onTargetAvailable: function({ isTopLevel, isTargetSwitching }) {
// Only care about top-level targets.
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}

Просмотреть файл

@ -722,8 +722,8 @@ Toolbox.prototype = {
* This method will be called for the top-level target, as well as any potential
* additional targets we may care about.
*/
async _onTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async _onTargetAvailable({ type, targetFront, isTopLevel }) {
if (isTopLevel) {
// Attach to a new top-level target.
// For now, register these event listeners only on the top level target
targetFront.on("will-navigate", this._onWillNavigate);
@ -736,19 +736,19 @@ Toolbox.prototype = {
});
}
await this._attachTarget(targetFront);
await this._attachTarget({ type, targetFront, isTopLevel });
if (this.hostType !== Toolbox.HostType.PAGE) {
await this.store.dispatch(registerTarget(targetFront));
}
if (targetFront.isTopLevel) {
if (isTopLevel) {
this.emit("top-target-attached");
}
},
_onTargetDestroyed({ targetFront }) {
if (targetFront.isTopLevel) {
_onTargetDestroyed({ type, targetFront, isTopLevel }) {
if (isTopLevel) {
this.detachTarget();
}
@ -764,7 +764,7 @@ Toolbox.prototype = {
* And we listen for thread actor events in order to update toolbox UI when
* we hit a breakpoint.
*/
async _attachTarget(targetFront) {
async _attachTarget({ type, targetFront, isTopLevel }) {
await targetFront.attach();
// Start tracking network activity on toolbox open for targets such as tabs.
@ -775,13 +775,10 @@ Toolbox.prototype = {
// already tracked by the content process targets. At least in the context
// of the Browser Toolbox.
// We would have to revisit that for the content toolboxes.
if (
targetFront.isTopLevel ||
targetFront.targetType != TargetList.TYPES.FRAME
) {
if (isTopLevel || type != TargetList.TYPES.FRAME) {
const threadFront = await this._attachAndResumeThread(targetFront);
this._startThreadFrontListeners(threadFront);
if (targetFront.isTopLevel) {
if (isTopLevel) {
this._threadFront = threadFront;
}
}

Просмотреть файл

@ -445,8 +445,8 @@ class AnimationInspector {
this.inspector.store.dispatch(updateSidebarSize(size));
}
async onTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async onTargetAvailable({ isTopLevel, targetFront }) {
if (isTopLevel) {
this.animationsFront = await targetFront.getFront("animations");
this.animationsFront.setWalkerActor(this.inspector.walker);
this.animationsFront.on("mutations", this.onAnimationsMutation);

Просмотреть файл

@ -126,26 +126,26 @@ class ChangesView {
changesFront.off("clear-changes", this.onClearChanges);
}
async onTargetAvailable({ targetFront }) {
async onTargetAvailable({ type, targetFront, isTopLevel }) {
targetFront.watchFronts(
"changes",
this.onChangesFrontAvailable,
this.onChangesFrontDestroyed
);
if (targetFront.isTopLevel) {
if (isTopLevel) {
targetFront.on("will-navigate", this.onClearChanges);
}
}
async onTargetDestroyed({ targetFront }) {
async onTargetDestroyed({ type, targetFront, isTopLevel }) {
targetFront.unwatchFronts(
"changes",
this.onChangesFrontAvailable,
this.onChangesFrontDestroyed
);
if (targetFront.isTopLevel) {
if (isTopLevel) {
targetFront.off("will-navigate", this.onClearChanges);
}
}

Просмотреть файл

@ -213,9 +213,9 @@ Inspector.prototype = {
return this._deferredOpen();
},
async _onTargetAvailable({ targetFront }) {
async _onTargetAvailable({ type, targetFront, isTopLevel }) {
// Ignore all targets but the top level one
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}
@ -229,9 +229,9 @@ Inspector.prototype = {
]);
},
_onTargetDestroyed({ targetFront }) {
_onTargetDestroyed({ type, targetFront, isTopLevel }) {
// Ignore all targets but the top level one
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}
targetFront.off("will-navigate", this._onBeforeNavigate);

Просмотреть файл

@ -59,7 +59,7 @@ class WalkerEventListener {
);
}
async _onTargetAvailable({ targetFront }) {
async _onTargetAvailable({ type, targetFront, isTopLevel }) {
const inspectorFront = await targetFront.getFront("inspector");
const { walker } = inspectorFront;
for (const [name, listener] of Object.entries(this._listenerMap)) {
@ -67,7 +67,7 @@ class WalkerEventListener {
}
}
_onTargetDestroyed({ targetFront }) {
_onTargetDestroyed({ type, targetFront, isTopLevel }) {
const inspectorFront = targetFront.getCachedFront("inspector");
if (inspectorFront) {
const { walker } = inspectorFront;

Просмотреть файл

@ -44,8 +44,8 @@ MemoryPanel.prototype = {
return this;
},
async _onTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async _onTargetAvailable({ targetFront, isTopLevel }) {
if (isTopLevel) {
const front = await targetFront.getFront("memory");
await front.attach();
this.initializer.updateFront(front);

Просмотреть файл

@ -117,8 +117,8 @@ class FirefoxConnector {
await this.addListeners();
}
async onTargetAvailable({ targetFront, isTargetSwitching }) {
if (!targetFront.isTopLevel) {
async onTargetAvailable({ targetFront, isTopLevel, isTargetSwitching }) {
if (!isTopLevel) {
return;
}

Просмотреть файл

@ -116,9 +116,11 @@ PerformancePanel.prototype = {
* @param {TargetFront} - targetFront
* As we are watching only FRAME type for this panel,
* the target should be a instance of BrowsingContextTarget.
* @param {Boolean} - isTopLevel
* true if the target is a full page.
*/
async _handleTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async _handleTargetAvailable({ targetFront, isTopLevel }) {
if (isTopLevel) {
const { PerformanceController, PerformanceView } = this.panelWin;
const performanceFront = await targetFront.getFront("performance");

Просмотреть файл

@ -1177,8 +1177,8 @@ class ResponsiveUI {
return this.browserWindow;
}
async onTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async onTargetAvailable({ isTopLevel, targetFront }) {
if (isTopLevel) {
this.responsiveFront = await targetFront.getFront("responsive");
await this.restoreActorState();
}

Просмотреть файл

@ -279,10 +279,10 @@ class StorageUI {
);
}
async _onTargetAvailable({ targetFront }) {
async _onTargetAvailable({ type, targetFront, isTopLevel }) {
// Only support top level target and navigation to new processes.
// i.e. ignore additional targets created for remote <iframes>
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}
@ -324,10 +324,10 @@ class StorageUI {
}
}
_onTargetDestroyed({ targetFront }) {
_onTargetDestroyed({ type, targetFront, isTopLevel }) {
// Only support top level target and navigation to new processes.
// i.e. ignore additional targets created for remote <iframes>
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}

Просмотреть файл

@ -1133,8 +1133,8 @@ StyleEditorUI.prototype = {
this.selectStyleSheet(source, location.line - 1, location.column - 1);
},
async _onTargetAvailable({ targetFront }) {
if (targetFront.isTopLevel) {
async _onTargetAvailable({ targetFront, isTopLevel }) {
if (isTopLevel) {
await this.initializeHighlighter(targetFront);
const stylesheetsFront = await targetFront.getFront("stylesheets");
@ -1146,8 +1146,8 @@ StyleEditorUI.prototype = {
}
},
async _onTargetDestroyed({ targetFront }) {
if (targetFront.isTopLevel) {
async _onTargetDestroyed({ isTopLevel }) {
if (isTopLevel) {
this._clear();
}
},

Просмотреть файл

@ -373,25 +373,34 @@ class WebConsoleUI {
* i.e. it was already existing or has just been created.
*
* @private
* @param string type
* One of the string of TargetList.TYPES to describe which
* type of target is available.
* @param Front targetFront
* The Front of the target that is available.
* This Front inherits from TargetMixin and is typically
* composed of a BrowsingContextTargetFront or ContentProcessTargetFront.
* @param boolean isTopLevel
* If true, means that this is the top level target.
* This typically happens on startup, providing the current
* top level target. But also on navigation, when we navigate
* to an URL which has to be loaded in a distinct process.
* A new top level target is created.
*/
async _onTargetAvailable({ targetFront }) {
async _onTargetAvailable({ type, targetFront, isTopLevel }) {
const dispatchTargetAvailable = () => {
const store = this.wrapper && this.wrapper.getStore();
if (store) {
this.wrapper.getStore().dispatch({
type: constants.TARGET_AVAILABLE,
targetType: targetFront.targetType,
targetType: type,
});
}
};
// This is a top level target. It may update on process switches
// when navigating to another domain.
if (targetFront.isTopLevel) {
if (isTopLevel) {
const fissionSupport = Services.prefs.getBoolPref(
constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
);
@ -416,9 +425,8 @@ class WebConsoleUI {
isContentToolbox &&
Services.prefs.getBoolPref("devtools.contenttoolbox.fission");
if (
targetFront.targetType != this.hud.targetList.TYPES.PROCESS &&
(targetFront.targetType != this.hud.targetList.TYPES.FRAME ||
!listenForFrames)
type != this.hud.targetList.TYPES.PROCESS &&
(type != this.hud.targetList.TYPES.FRAME || !listenForFrames)
) {
return;
}
@ -434,8 +442,8 @@ class WebConsoleUI {
* @private
* See _onTargetAvailable for param's description.
*/
_onTargetDestroyed({ targetFront }) {
if (targetFront.isTopLevel) {
_onTargetDestroyed({ type, targetFront, isTopLevel }) {
if (isTopLevel) {
this.proxy.disconnect();
this.proxy = null;
} else {

Просмотреть файл

@ -6,7 +6,9 @@
module.exports = async function({
targetList,
targetType,
targetFront,
isTopLevel,
isFissionEnabledOnContentToolbox,
onAvailable,
}) {
@ -18,9 +20,9 @@ module.exports = async function({
const isContentToolbox = targetList.targetFront.isLocalTab;
const listenForFrames = isContentToolbox && isFissionEnabledOnContentToolbox;
const isAllowed =
targetFront.isTopLevel ||
targetFront.targetType === targetList.TYPES.PROCESS ||
(targetFront.targetType === targetList.TYPES.FRAME && listenForFrames);
isTopLevel ||
targetType === targetList.TYPES.PROCESS ||
(targetType === targetList.TYPES.FRAME && listenForFrames);
if (!isAllowed) {
return;

Просмотреть файл

@ -6,7 +6,9 @@
module.exports = async function({
targetList,
targetType,
targetFront,
isTopLevel,
isFissionEnabledOnContentToolbox,
onAvailable,
}) {
@ -18,9 +20,9 @@ module.exports = async function({
const isContentToolbox = targetList.targetFront.isLocalTab;
const listenForFrames = isContentToolbox && isFissionEnabledOnContentToolbox;
const isAllowed =
targetFront.isTopLevel ||
targetFront.targetType === targetList.TYPES.PROCESS ||
(targetFront.targetType === targetList.TYPES.FRAME && listenForFrames);
isTopLevel ||
targetType === targetList.TYPES.PROCESS ||
(targetType === targetList.TYPES.FRAME && listenForFrames);
if (!isAllowed) {
return;

Просмотреть файл

@ -4,13 +4,17 @@
"use strict";
module.exports = async function({ targetList, targetFront, onAvailable }) {
module.exports = async function({
targetList,
targetType,
targetFront,
isTopLevel,
onAvailable,
}) {
// Only allow the top level target and processes.
// Frames can be ignored as logMessage are never sent to them anyway.
// Also ignore workers as they are not supported yet. (see bug 1592584)
const isAllowed =
targetFront.isTopLevel ||
targetFront.targetType === targetList.TYPES.PROCESS;
const isAllowed = isTopLevel || targetType === targetList.TYPES.PROCESS;
if (!isAllowed) {
return;
}

Просмотреть файл

@ -4,8 +4,14 @@
"use strict";
module.exports = async function({ targetList, targetFront, onAvailable }) {
if (!targetFront.isTopLevel) {
module.exports = async function({
targetList,
targetType,
targetFront,
isTopLevel,
onAvailable,
}) {
if (!isTopLevel) {
return;
}

Просмотреть файл

@ -136,12 +136,21 @@ class ResourceWatcher {
/**
* Method called by the TargetList for each already existing or target which has just been created.
*
* @param {string} type
* One of the string of TargetList.TYPES to describe which
* type of target is available.
* @param {Front} targetFront
* The Front of the target that is available.
* This Front inherits from TargetMixin and is typically
* composed of a BrowsingContextTargetFront or ContentProcessTargetFront.
* @param {boolean} isTopLevel
* If true, means that this is the top level target.
* This typically happens on startup, providing the current
* top level target. But also on navigation, when we navigate
* to an URL which has to be loaded in a distinct process.
* A new top level target is created.
*/
async _onTargetAvailable({ targetFront }) {
async _onTargetAvailable({ type, targetFront, isTopLevel }) {
// For each resource type...
for (const resourceType of Object.values(ResourceWatcher.TYPES)) {
// ...which has at least one listener...
@ -149,7 +158,12 @@ class ResourceWatcher {
continue;
}
// ...request existing resource and new one to come from this one target
await this._watchResourcesForTarget(targetFront, resourceType);
await this._watchResourcesForTarget(
type,
targetFront,
isTopLevel,
resourceType
);
}
}
@ -157,7 +171,7 @@ class ResourceWatcher {
* Method called by the TargetList when a target has just been destroyed
* See _onTargetAvailable for arguments, they are the same.
*/
_onTargetDestroyed({ targetFront }) {
_onTargetDestroyed({ type, targetFront }) {
//TODO: Is there a point in doing anything?
//
// We could remove the available/destroyed event, but as the target is destroyed
@ -255,7 +269,14 @@ class ResourceWatcher {
for (const targetType of this.targetList.ALL_TYPES) {
// XXX: May be expose a getReallyAllTarget() on TargetList?
for (const target of this.targetList.getAllTargets(targetType)) {
promises.push(this._watchResourcesForTarget(target, resourceType));
promises.push(
this._watchResourcesForTarget(
targetType,
target,
target == this.targetList.targetFront,
resourceType
)
);
}
}
await Promise.all(promises);
@ -265,7 +286,7 @@ class ResourceWatcher {
* Call backward compatibility code from `LegacyListeners` in order to listen for a given
* type of resource from a given target.
*/
_watchResourcesForTarget(targetFront, resourceType) {
_watchResourcesForTarget(targetType, targetFront, isTopLevel, resourceType) {
const onAvailable = this._onResourceAvailable.bind(
this,
targetFront,
@ -273,7 +294,9 @@ class ResourceWatcher {
);
return LegacyListeners[resourceType]({
targetList: this.targetList,
targetType,
targetFront,
isTopLevel,
isFissionEnabledOnContentToolbox: this.contentToolboxFissionPrefValue,
onAvailable,
});
@ -344,11 +367,13 @@ const LegacyListeners = {
.PLATFORM_MESSAGES]: require("devtools/shared/resources/legacy-listeners/platform-messages"),
async [ResourceWatcher.TYPES.DOCUMENT_EVENTS]({
targetList,
targetType,
targetFront,
isTopLevel,
onAvailable,
}) {
// DocumentEventsListener of webconsole handles only top level document.
if (!targetFront.isTopLevel) {
if (!isTopLevel) {
return;
}

Просмотреть файл

@ -127,22 +127,28 @@ class TargetList {
// Map the descriptor typeName to a target type.
const targetType = this.getTargetType(targetFront);
const isTopLevel = targetFront == this.targetFront;
targetFront.setTargetType(targetType);
targetFront.setIsTopLevel(targetFront == this.targetFront);
targetFront.setIsTopLevel(isTopLevel);
this._targets.add(targetFront);
// Notify the target front creation listeners
await this._createListeners.emitAsync(targetType, {
type: targetType,
targetFront,
isTopLevel,
isTargetSwitching,
});
}
_onTargetDestroyed(targetFront, isTargetSwitching = false) {
this._destroyListeners.emit(targetFront.targetType, {
const targetType = targetFront.targetType;
this._destroyListeners.emit(targetType, {
type: targetType,
targetFront,
isTopLevel: targetFront.isTopLevel,
isTargetSwitching,
});
this._targets.delete(targetFront);
@ -295,8 +301,10 @@ class TargetList {
* The type of target to listen for. Constant of TargetList.TYPES.
* @param {Function} onAvailable
* Callback fired when a target has been just created or was already available.
* The function is called with the following arguments:
* The function is called with three arguments:
* - {String} type: The target type
* - {TargetFront} targetFront: The target Front
* - {Boolean} isTopLevel: Is this target the top level one?
* - {Boolean} isTargetSwitching: Is this target relates to a navigation and
* this replaced a previously available target, this flag will be true
* @param {Function} onDestroy
@ -319,7 +327,9 @@ class TargetList {
// which may setup things regarding the existing targets
// and listen callsite may care about the full initialization
await onAvailable({
type: targetFront.targetType,
targetFront,
isTopLevel: targetFront == this.targetFront,
isTargetSwitching: false,
});
} catch (e) {

Просмотреть файл

@ -61,15 +61,15 @@ async function testBrowserFrames(mainRoot) {
// Assert that watchTargets will call the create callback for all existing frames
const targets = [];
const onAvailable = ({ targetFront }) => {
const onAvailable = ({ type, targetFront, isTopLevel }) => {
is(
targetFront.targetType,
type,
TargetList.TYPES.FRAME,
"We are only notified about frame targets"
);
ok(
targetFront == target ? targetFront.isTopLevel : !targetFront.isTopLevel,
"isTopLevel property is correct"
targetFront == target ? isTopLevel : !isTopLevel,
"isTopLevel argument is correct"
);
targets.push(targetFront);
};
@ -125,15 +125,15 @@ async function testTabFrames(mainRoot) {
// Assert that watchTargets will call the create callback for all existing frames
const targets = [];
const onAvailable = ({ targetFront }) => {
const onAvailable = ({ type, targetFront, isTopLevel }) => {
is(
targetFront.targetType,
type,
TargetList.TYPES.FRAME,
"We are only notified about frame targets"
);
ok(
targetFront == target ? targetFront.isTopLevel : !targetFront.isTopLevel,
"isTopLevel property is correct"
targetFront == target ? isTopLevel : !isTopLevel,
"isTopLevel argument is correct"
);
targets.push(targetFront);
};

Просмотреть файл

@ -60,7 +60,7 @@ async function testPreffedOffMainProcess(mainRoot, mainProcess) {
);
const processTargets = [];
const onProcessAvailable = ({ targetFront }) => {
const onProcessAvailable = ({ type, targetFront, isTopLevel }) => {
processTargets.push(targetFront);
};
await targetList.watchTargets([TargetList.TYPES.PROCESS], onProcessAvailable);
@ -68,16 +68,13 @@ async function testPreffedOffMainProcess(mainRoot, mainProcess) {
targetList.unwatchTargets([TargetList.TYPES.PROCESS], onProcessAvailable);
const frameTargets = [];
const onFrameAvailable = ({ targetFront }) => {
const onFrameAvailable = ({ type, targetFront, isTopLevel }) => {
is(
targetFront.targetType,
type,
TargetList.TYPES.FRAME,
"We are only notified about frame targets"
);
ok(
targetFront.isTopLevel,
"We are only notified about the top level target"
);
ok(isTopLevel, "We are only notified about the top level target");
frameTargets.push(targetFront);
};
await targetList.watchTargets([TargetList.TYPES.FRAME], onFrameAvailable);
@ -126,16 +123,13 @@ async function testPreffedOffTab(mainRoot) {
targetList.unwatchTargets([TargetList.TYPES.PROCESS], onProcessAvailable);
const frameTargets = [];
const onFrameAvailable = ({ targetFront }) => {
const onFrameAvailable = ({ type, targetFront, isTopLevel }) => {
is(
targetFront.targetType,
type,
TargetList.TYPES.FRAME,
"We are only notified about frame targets"
);
ok(
targetFront.isTopLevel,
"We are only notified about the top level target"
);
ok(isTopLevel, "We are only notified about the top level target");
frameTargets.push(targetFront);
};
await targetList.watchTargets([TargetList.TYPES.FRAME], onFrameAvailable);

Просмотреть файл

@ -62,22 +62,22 @@ async function testProcesses(targetList, target) {
// Assert that watchTargets will call the create callback for all existing frames
const targets = new Set();
const onAvailable = ({ targetFront }) => {
const onAvailable = ({ type, targetFront, isTopLevel }) => {
if (targets.has(targetFront)) {
ok(false, "The same target is notified multiple times via onAvailable");
}
is(
targetFront.targetType,
type,
TargetList.TYPES.PROCESS,
"We are only notified about process targets"
);
ok(
targetFront == target ? targetFront.isTopLevel : !targetFront.isTopLevel,
"isTopLevel property is correct"
targetFront == target ? isTopLevel : !isTopLevel,
"isTopLevel argument is correct"
);
targets.add(targetFront);
};
const onDestroyed = ({ targetFront }) => {
const onDestroyed = ({ type, targetFront, isTopLevel }) => {
if (!targets.has(targetFront)) {
ok(
false,
@ -85,12 +85,12 @@ async function testProcesses(targetList, target) {
);
}
is(
targetFront.targetType,
type,
TargetList.TYPES.PROCESS,
"We are only notified about process targets"
);
ok(
!targetFront.isTopLevel,
!isTopLevel,
"We are never notified about the top level target destruction"
);
targets.delete(targetFront);
@ -115,7 +115,7 @@ async function testProcesses(targetList, target) {
const previousTargets = new Set(targets);
// Assert that onAvailable is called for processes created *after* the call to watchTargets
const onProcessCreated = new Promise(resolve => {
const onAvailable2 = ({ targetFront }) => {
const onAvailable2 = ({ type, targetFront, isTopLevel }) => {
if (previousTargets.has(targetFront)) {
return;
}
@ -139,7 +139,7 @@ async function testProcesses(targetList, target) {
// Assert that onDestroyed is called for destroyed processes
const onProcessDestroyed = new Promise(resolve => {
const onAvailable3 = () => {};
const onDestroyed3 = ({ targetFront }) => {
const onDestroyed3 = ({ type, targetFront, isTopLevel }) => {
resolve(targetFront);
targetList.unwatchTargets(
[TargetList.TYPES.PROCESS],

Просмотреть файл

@ -47,19 +47,22 @@ async function testSwitchToTarget(client) {
const frameTargets = [];
let currentTarget = firstTarget;
const onFrameAvailable = ({ targetFront, isTargetSwitching }) => {
const onFrameAvailable = ({
type,
targetFront,
isTopLevel,
isTargetSwitching,
}) => {
is(
targetFront.targetType,
type,
TargetList.TYPES.FRAME,
"We are only notified about frame targets"
);
ok(
targetFront == currentTarget
? targetFront.isTopLevel
: !targetFront.isTopLevel,
"isTopLevel property is correct"
targetFront == currentTarget ? isTopLevel : !isTopLevel,
"isTopLevel argument is correct"
);
if (targetFront.isTopLevel) {
if (isTopLevel) {
// When calling watchTargets, this will be false, but it will be true when calling switchToTarget
is(
isTargetSwitching,
@ -72,19 +75,22 @@ async function testSwitchToTarget(client) {
frameTargets.push(targetFront);
};
const destroyedTargets = [];
const onFrameDestroyed = ({ targetFront, isTargetSwitching }) => {
const onFrameDestroyed = ({
type,
targetFront,
isTopLevel,
isTargetSwitching,
}) => {
is(
targetFront.targetType,
type,
TargetList.TYPES.FRAME,
"target-destroyed: We are only notified about frame targets"
);
ok(
targetFront == firstTarget
? targetFront.isTopLevel
: !targetFront.isTopLevel,
"target-destroyed: isTopLevel property is correct"
targetFront == firstTarget ? isTopLevel : !isTopLevel,
"target-destroyed: isTopLevel argument is correct"
);
if (targetFront.isTopLevel) {
if (isTopLevel) {
is(
isTargetSwitching,
true,

Просмотреть файл

@ -45,22 +45,22 @@ async function testWatchTargets(mainRoot) {
"Check that onAvailable is called for processes already created *before* the call to watchTargets"
);
const targets = new Set();
const onAvailable = ({ targetFront }) => {
const onAvailable = ({ type, targetFront, isTopLevel }) => {
if (targets.has(targetFront)) {
ok(false, "The same target is notified multiple times via onAvailable");
}
is(
targetFront.targetType,
type,
TargetList.TYPES.PROCESS,
"We are only notified about process targets"
);
ok(
targetFront == target ? targetFront.isTopLevel : !targetFront.isTopLevel,
"isTopLevel property is correct"
targetFront == target ? isTopLevel : !isTopLevel,
"isTopLevel argument is correct"
);
targets.add(targetFront);
};
const onDestroyed = ({ targetFront }) => {
const onDestroyed = ({ type, targetFront, isTopLevel }) => {
if (!targets.has(targetFront)) {
ok(
false,
@ -68,12 +68,12 @@ async function testWatchTargets(mainRoot) {
);
}
is(
targetFront.targetType,
type,
TargetList.TYPES.PROCESS,
"We are only notified about process targets"
);
ok(
!targetFront.isTopLevel,
!isTopLevel,
"We are not notified about the top level target destruction"
);
targets.delete(targetFront);
@ -105,7 +105,7 @@ async function testWatchTargets(mainRoot) {
);
const previousTargets = new Set(targets);
const onProcessCreated = new Promise(resolve => {
const onAvailable2 = ({ targetFront }) => {
const onAvailable2 = ({ type, targetFront, isTopLevel }) => {
if (previousTargets.has(targetFront)) {
return;
}
@ -130,7 +130,7 @@ async function testWatchTargets(mainRoot) {
// Assert that onDestroyed is called for destroyed processes
const onProcessDestroyed = new Promise(resolve => {
const onAvailable3 = () => {};
const onDestroyed3 = ({ targetFront }) => {
const onDestroyed3 = ({ type, targetFront, isTopLevel }) => {
resolve(targetFront);
targetList.unwatchTargets(
[TargetList.TYPES.PROCESS],
@ -185,25 +185,22 @@ async function testContentProcessTarget(mainRoot) {
// as listening for additional target is only enable for the parent process target.
// See bug 1593928.
const targets = new Set();
const onAvailable = ({ targetFront }) => {
const onAvailable = ({ type, targetFront, isTopLevel }) => {
if (targets.has(targetFront)) {
// This may fail if the top level target is reported by LegacyImplementation
// to TargetList and emits an available event for it.
ok(false, "The same target is notified multiple times via onAvailable");
}
is(
targetFront.targetType,
type,
TargetList.TYPES.PROCESS,
"We are only notified about process targets"
);
is(targetFront, target, "This is the existing top level target");
ok(
targetFront.isTopLevel,
"We are only notified about the top level target"
);
ok(isTopLevel, "We are only notified about the top level target");
targets.add(targetFront);
};
const onDestroyed = _ => {
const onDestroyed = ({ type, targetFront, isTopLevel }) => {
ok(false, "onDestroyed should never be called in this test");
};
await targetList.watchTargets(
@ -238,7 +235,7 @@ async function testThrowingInOnAvailable(mainRoot) {
);
const targets = new Set();
let thrown = false;
const onAvailable = ({ targetFront }) => {
const onAvailable = ({ type, targetFront, isTopLevel }) => {
if (!thrown) {
thrown = true;
throw new Error("Force an exception when processing the first target");

Просмотреть файл

@ -114,16 +114,16 @@ async function testBrowserWorkers(mainRoot) {
"Check that watchTargets will call the create callback for all existing workers"
);
const targets = [];
const onAvailable = async ({ targetFront }) => {
const onAvailable = async ({ type, targetFront, isTopLevel }) => {
ok(
targetFront.targetType === TYPES.WORKER ||
targetFront.targetType === TYPES.SHARED_WORKER ||
targetFront.targetType === TYPES.SERVICE_WORKER,
type === TYPES.WORKER ||
type === TYPES.SHARED_WORKER ||
type === TYPES.SERVICE_WORKER,
"We are only notified about worker targets"
);
ok(
targetFront == target ? targetFront.isTopLevel : !targetFront.isTopLevel,
"isTopLevel property is correct"
targetFront == target ? isTopLevel : !isTopLevel,
"isTopLevel argument is correct"
);
targets.push(targetFront);
};
@ -157,7 +157,7 @@ async function testBrowserWorkers(mainRoot) {
// Create a new worker and see if the worker target is reported
const onWorkerCreated = new Promise(resolve => {
const onAvailable2 = async ({ targetFront }) => {
const onAvailable2 = async ({ type, targetFront, isTopLevel }) => {
if (targets.includes(targetFront)) {
return;
}
@ -213,13 +213,9 @@ async function testTabWorkers(mainRoot, tab) {
// Assert that watchTargets will call the create callback for all existing workers
const targets = [];
const onAvailable = async ({ targetFront }) => {
is(
targetFront.targetType,
TYPES.WORKER,
"We are only notified about worker targets"
);
ok(!targetFront.isTopLevel, "The workers are never top level");
const onAvailable = async ({ type, targetFront, isTopLevel }) => {
is(type, TYPES.WORKER, "We are only notified about worker targets");
ok(!isTopLevel, "The workers are never top level");
targets.push(targetFront);
};
await targetList.watchTargets([TYPES.WORKER], onAvailable);