Skip to content

Commit

Permalink
Merge autoland to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Alexandru Michis committed Sep 10, 2020
2 parents 58d5c53 + 04b1352 commit e38edad
Show file tree
Hide file tree
Showing 68 changed files with 1,387 additions and 285 deletions.
28 changes: 4 additions & 24 deletions build/moz.configure/init.configure
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,6 @@ option(env='OLD_CONFIGURE', nargs=1, help='Path to the old configure script')

option(env='MOZCONFIG', nargs=1, help='Mozconfig location')

option('--with-external-source-dir', env='EXTERNAL_SOURCE_DIR', nargs=1,
help='External directory containing additional build files')


@depends('--with-external-source-dir')
def external_source_dir(value):
if value:
return value[0]


set_config('EXTERNAL_SOURCE_DIR', external_source_dir)
add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)

# Read user mozconfig
# ==============================================================
Expand All @@ -155,13 +143,11 @@ add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)
# be called when --help is passed, and the mozconfig wouldn't be read.


@depends('MOZCONFIG', 'OLD_CONFIGURE',
check_build_environment, '--with-external-source-dir',
@depends('MOZCONFIG', 'OLD_CONFIGURE', check_build_environment,
'--help')
@imports(_from='mozbuild.mozconfig', _import='MozconfigLoader')
@imports(_from='mozboot.mozconfig', _import='find_mozconfig')
def mozconfig(mozconfig, old_configure, build_env,
external_source_dir, help):
def mozconfig(mozconfig, old_configure, build_env, help):
if not old_configure and not help:
die('The OLD_CONFIGURE environment variable must be set')

Expand All @@ -185,8 +171,6 @@ def mozconfig(mozconfig, old_configure, build_env,
return {'path': None}

topsrcdir = build_env.topsrcdir
if external_source_dir:
topsrcdir = external_source_dir[0]
loader = MozconfigLoader(topsrcdir)
mozconfig = mozconfig[0] if mozconfig else None
mozconfig = find_mozconfig(topsrcdir, env={'MOZCONFIG': mozconfig})
Expand Down Expand Up @@ -1100,17 +1084,13 @@ def target_is_sparc(target):
set_define('SPARC64', target_is_sparc)


@depends('--enable-project', '--with-external-source-dir',
check_build_environment, '--help')
@depends('--enable-project', check_build_environment, '--help')
@imports(_from='os.path', _import='exists')
def include_project_configure(project, external_source_dir, build_env, help):
def include_project_configure(project, build_env, help):
if not project:
die('--enable-project is required.')

base_dir = build_env.topsrcdir
if external_source_dir:
base_dir = os.path.join(base_dir, external_source_dir[0])

path = os.path.join(base_dir, project[0], 'moz.configure')
if not exists(path):
die('Cannot find project %s', project[0])
Expand Down
5 changes: 5 additions & 0 deletions devtools/client/debugger/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ class DebuggerPanel {
}

destroy() {
const resourceWatcher = this.toolbox.resourceWatcher;
resourceWatcher.unwatchResources([resourceWatcher.TYPES.ERROR_MESSAGE], {
onAvailable: this._actions.addExceptionFromResources,
});

this.panelWin.Debugger.destroy();
this.emit("destroyed");
}
Expand Down
7 changes: 6 additions & 1 deletion devtools/client/framework/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,10 @@ Toolbox.prototype = {
// there is always at least one listener existing for network events across
// the lifetime of the various panels, so stopping the resource watcher from
// clearing out its cache of network event resources.
this.noopNetworkEventListener = () => {};
await this.resourceWatcher.watchResources(
[this.resourceWatcher.TYPES.NETWORK_EVENT],
{ onAvailable: () => {}, onUpdated: () => {} }
{ onAvailable: this.noopNetworkEventListener }
);

await domReady;
Expand Down Expand Up @@ -3642,6 +3643,10 @@ Toolbox.prototype = {
this._onTargetAvailable,
this._onTargetDestroyed
);
this.resourceWatcher.unwatchResources(
[this.resourceWatcher.TYPES.NETWORK_EVENT],
{ onAvailable: this.noopNetworkEventListener }
);

this.targetList.destroy();

Expand Down
9 changes: 7 additions & 2 deletions devtools/client/inspector/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -1671,11 +1671,16 @@ Inspector.prototype = {
this.styleChangeTracker.destroy();
this.searchboxShortcuts.destroy();

this.toolbox.targetList.unwatchTargets(
[this.toolbox.targetList.TYPES.FRAME],
const { targetList, resourceWatcher } = this.toolbox;
targetList.unwatchTargets(
[targetList.TYPES.FRAME],
this._onTargetAvailable,
this._onTargetDestroyed
);
resourceWatcher.unwatchResources(
[resourceWatcher.TYPES.ROOT_NODE, resourceWatcher.TYPES.CSS_CHANGE],
{ onAvailable: this.onResourceAvailable }
);

this._is3PaneModeChromeEnabled = null;
this._is3PaneModeEnabled = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ async function navigateIframeTo(inspector, url) {
const { resourceWatcher, targetList } = inspector.toolbox;
const onTargetProcessed = waitForTargetProcessed(targetList, url);

const onNewRoot = waitForResourceOnce(
const onNewRoot = waitForNextResource(
resourceWatcher,
resourceWatcher.TYPES.ROOT_NODE
resourceWatcher.TYPES.ROOT_NODE,
{
ignoreExistingResources: true,
}
);

info("Update the src attribute of the iframe tag");
Expand Down
2 changes: 1 addition & 1 deletion devtools/client/performance/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ PerformancePanel.prototype = {
this._checkRecordingStatus
);

await this.toolbox.targetList.unwatchTargets(
this.toolbox.targetList.unwatchTargets(
[this.toolbox.targetList.TYPES.FRAME],
this._onTargetAvailable
);
Expand Down
24 changes: 20 additions & 4 deletions devtools/client/shared/test/shared-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,18 +1181,34 @@ function getCurrentTestFilePath() {
* The ResourceWatcher instance that should emit the expected resource.
* @param {String} resourceType
* One of ResourceWatcher.TYPES, type of the expected resource.
* @param {Object} additional options
* - {Boolean} ignoreExistingResources: ignore existing resources or not.
* - {Function} predicate: if provided, will wait until a resource makes
* predicate(resource) return true.
* @return {Object}
* - resource {Object} the resource itself
* - targetFront {TargetFront} the target which owns the resource
*/
function waitForResourceOnce(resourceWatcher, resourceType) {
function waitForNextResource(
resourceWatcher,
resourceType,
{ ignoreExistingResources = false, predicate } = {}
) {
// If no predicate was provided, convert to boolean to avoid resolving for
// empty `resources` arrays.
predicate = predicate || (resource => !!resource);

return new Promise(resolve => {
const onAvailable = resources => {
resolve(resources[0]);
resourceWatcher.unwatchResources([resourceType], { onAvailable });
const matchingResource = resources.find(resource => predicate(resource));
if (matchingResource) {
resolve(matchingResource);
resourceWatcher.unwatchResources([resourceType], { onAvailable });
}
};

resourceWatcher.watchResources([resourceType], {
ignoreExistingResources: true,
ignoreExistingResources,
onAvailable,
});
});
Expand Down
1 change: 1 addition & 0 deletions devtools/client/webconsole/webconsole-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class WebConsoleUI {
resourceWatcher.TYPES.ERROR_MESSAGE,
resourceWatcher.TYPES.PLATFORM_MESSAGE,
resourceWatcher.TYPES.NETWORK_EVENT,
resourceWatcher.TYPES.NETWORK_EVENT_STACKTRACE,
],
{
onAvailable: this._onResourceAvailable,
Expand Down
1 change: 0 additions & 1 deletion devtools/server/actors/animation-type-longhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [
"-moz-box-orient",
"-moz-box-pack",
"box-sizing",
"-moz-button-appearance",
"caption-side",
"clear",
"clip-rule",
Expand Down
13 changes: 13 additions & 0 deletions devtools/shared/protocol/Actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class Actor extends Pool {
console.error(error.stack);
}

// Do not try to send the error if the actor is destroyed
// as the connection is probably also destroyed and may throw.
if (this.isDestroyed()) {
return;
}

this.conn.send({
from: this.actorID,
// error.error -> errors created using the throwError() helper
Expand Down Expand Up @@ -170,6 +176,13 @@ var generateRequestHandlers = function(actorSpec, actorProto) {
// No need to send a response.
return;
}
if (this.isDestroyed()) {
console.error(
`Tried to send a '${spec.name}' method reply on an already destroyed actor` +
` '${this.typeName}'`
);
return;
}

let response;
try {
Expand Down
23 changes: 11 additions & 12 deletions devtools/shared/resources/resource-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,22 @@ class ResourceWatcher {
* It will only listen for types which are defined by `TargetList.startListening`.
*/
async _watchAllTargets() {
if (this._isWatchingTargets) {
return;
if (!this._watchTargetsPromise) {
this._watchTargetsPromise = this.targetList.watchTargets(
this.targetList.ALL_TYPES,
this._onTargetAvailable,
this._onTargetDestroyed
);
}
this._isWatchingTargets = true;
await this.targetList.watchTargets(
this.targetList.ALL_TYPES,
this._onTargetAvailable,
this._onTargetDestroyed
);
return this._watchTargetsPromise;
}

async _unwatchAllTargets() {
if (!this._isWatchingTargets) {
_unwatchAllTargets() {
if (!this._watchTargetsPromise) {
return;
}
this._isWatchingTargets = false;
await this.targetList.unwatchTargets(
this._watchTargetsPromise = null;
this.targetList.unwatchTargets(
this.targetList.ALL_TYPES,
this._onTargetAvailable,
this._onTargetDestroyed
Expand Down
2 changes: 1 addition & 1 deletion devtools/shared/resources/target-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class TargetList extends EventEmitter {
* Stop listening for the creation and/or destruction of a given type of target fronts.
* See `watchTargets()` for documentation of the arguments.
*/
async unwatchTargets(types, onAvailable, onDestroy) {
unwatchTargets(types, onAvailable, onDestroy) {
if (typeof onAvailable != "function") {
throw new Error(
"TargetList.unwatchTargets expects a function as second argument"
Expand Down
1 change: 1 addition & 0 deletions devtools/shared/resources/tests/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ skip-if = os == "linux" #Bug 1655183
[browser_resources_several_resources.js]
[browser_resources_stylesheets.js]
[browser_resources_target_destroy.js]
[browser_resources_target_resources_race.js]
[browser_resources_websocket.js]
[browser_target_list_browser_workers.js]
[browser_target_list_frames.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");

/**
* Test initial target resources are correctly retrieved even when several calls
* to watchResources are made simultaneously.
*
* This checks a race condition which occurred when calling watchResources
* simultaneously. This made the "second" call to watchResources miss existing
* resources (in case those are emitted from the target instead of the watcher).
* See Bug 1663896.
*/
add_task(async function() {
// Disable the preloaded process as it creates processes intermittently
// which forces the emission of RDP requests we aren't correctly waiting for.
await pushPref("dom.ipc.processPrelaunch.enabled", false);

const {
client,
resourceWatcher,
targetList,
} = await initResourceWatcherAndTarget();

const expectedPlatformMessage = "expectedMessage";

info("Log a message *before* calling ResourceWatcher.watchResources");
Services.console.logStringMessage(expectedPlatformMessage);

info("Call watchResources from 2 separate call sites consecutively");

// Empty onAvailable callback for CSS MESSAGES, we only want to check that
// the second resource we watch correctly provides existing resources.
const onCssMessageAvailable = resources => {};

// First call to watchResources.
// We do not await on `watchPromise1` here, in order to simulate simultaneous
// calls to watchResources (which could come from 2 separate modules in a real
// scenario).
const initialWatchPromise = resourceWatcher.watchResources(
[ResourceWatcher.TYPES.CSS_MESSAGE],
{
onAvailable: onCssMessageAvailable,
}
);

// `waitForNextResource` will trigger another call to `watchResources`.
const onMessageReceived = waitForNextResource(
resourceWatcher,
ResourceWatcher.TYPES.PLATFORM_MESSAGE,
{
ignoreExistingResources: false,
predicate: r => r.message === expectedPlatformMessage,
}
);

info("Waiting for the expected message to be received");
await onMessageReceived;
ok(true, "All the expected messages were received");

info("Wait for the other watchResources promise to finish");
await initialWatchPromise;

// Unwatch all resources.
resourceWatcher.unwatchResources([ResourceWatcher.TYPES.CSS_MESSAGE], {
onAvailable: onCssMessageAvailable,
});

Services.console.reset();
targetList.destroy();
await client.close();
});
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async function testProcesses(targetList, target) {
"The destroyed target is the one that has been reported as created"
);

await targetList.unwatchTargets(
targetList.unwatchTargets(
[TargetList.TYPES.PROCESS],
onAvailable,
onDestroyed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async function testWatchTargets(mainRoot) {
"The destroyed target is the one that has been reported as created"
);

await targetList.unwatchTargets(
targetList.unwatchTargets(
[TargetList.TYPES.PROCESS],
onAvailable,
onDestroyed
Expand Down
Loading

0 comments on commit e38edad

Please sign in to comment.