Backed out 11 changesets (bug 1680218) for causing devtools failures e.g. /browser_rules_add-rule-and-property.js. CLOSED TREE

Backed out changeset a17c7da1221c (bug 1680218)
Backed out changeset 2cbd9d935611 (bug 1680218)
Backed out changeset 58034e6bc337 (bug 1680218)
Backed out changeset 9e668aa17d1c (bug 1680218)
Backed out changeset 082988607e17 (bug 1680218)
Backed out changeset 63d5d5fb0feb (bug 1680218)
Backed out changeset d09c87a11d72 (bug 1680218)
Backed out changeset 37adf02276eb (bug 1680218)
Backed out changeset 5103a959e33d (bug 1680218)
Backed out changeset 34838b56270b (bug 1680218)
Backed out changeset 936c49ae59a4 (bug 1680218)
This commit is contained in:
Csoregi Natalia 2020-12-09 10:01:41 +02:00
Родитель 652218e11d
Коммит 0c82325a1d
22 изменённых файлов: 268 добавлений и 78 удалений

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

@ -31,7 +31,22 @@ exports.PREFERENCE_TYPES = PREFERENCE_TYPES;
* PreferenceFront.
* - type {String}: the preference type (either BOOL, CHAR or INT).
*/
const DEFAULT_PREFERENCES = [];
const DEFAULT_PREFERENCES = [
// @backward-compat { version 82 } Fixed on the server by Bug 1662058.
{
prefName: "devtools.inspector.compatibility.target-browsers",
defaultValue: "",
trait: "targetBrowsersPref",
type: PREFERENCE_TYPES.CHAR,
},
// @backward-compat { version 82 } Fixed on the server by Bug 1659866.
{
prefName: "devtools.overflow.debugging.enabled",
defaultValue: false,
trait: "overflowDebuggingPref",
type: PREFERENCE_TYPES.BOOL,
},
];
exports.DEFAULT_PREFERENCES = DEFAULT_PREFERENCES;
const METHODS = {
@ -54,18 +69,15 @@ const METHODS = {
* corresponding to the provided clientWrapper, if needed.
*
* Note: prefDescriptors will most likely be DEFAULT_PREFERENCES when
* used in production code, but can be parameterized for tests.
* used in production code, but can be parametrized for tests.
*
* @param {ClientWrapper} clientWrapper
* @param {Array} prefDescriptors
* Array of preference descriptors, see DEFAULT_PREFERENCES.
*/
async function setDefaultPreferencesIfNeeded(clientWrapper, prefDescriptors) {
if (!prefDescriptors || prefDescriptors.length === 0) {
return;
}
const preferenceFront = await clientWrapper.getFront("preference");
const preferenceTraits = await preferenceFront.getTraits();
// Note: using Promise.all here fails because the request/responses get mixed.

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

@ -88,12 +88,19 @@ class WorkerDescriptorFront extends TargetMixin(
return;
}
const workerTargetForm = await super.getTarget();
// Immediately retrieve console and thread actors that will be later used by Target.
let connectResponse;
if (this.actorID.includes("workerDescriptor")) {
connectResponse = await super.getTarget();
} else {
// @backward-compat { version 83 } Older servers don't support worker descriptors.
connectResponse = await this.connect({});
}
// Set the console actor ID on the form to expose it to Target.attachConsole
// Set the ThreadActor on the target form so it is accessible by getFront
this.targetForm.consoleActor = workerTargetForm.consoleActor;
this.targetForm.threadActor = workerTargetForm.threadActor;
this.targetForm.consoleActor = connectResponse.consoleActor;
this.targetForm.threadActor = connectResponse.threadActor;
if (this.isDestroyedOrBeingDestroyed()) {
return;

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

@ -321,6 +321,12 @@ class NodeFront extends FrontClassWithSpec(nodeSpec) {
return this._form.isTopLevelDocument;
}
// @backward-compat { version 81 } On newer server, this is never called; `isTopLevelDocument`
// is returned from the server.
set isTopLevelDocument(isTopLevelDocument) {
this._form.isTopLevelDocument = isTopLevelDocument;
}
get isShadowRoot() {
return this._form.isShadowRoot;
}

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

@ -80,7 +80,7 @@ class PageStyleFront extends FrontClassWithSpec(pageStyleSpec) {
throw new Error("`type` should not be empty");
}
if (!search) {
if (!this._form.traits.getAttributesInOwnerDocument || !search) {
return [];
}

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

@ -19,10 +19,16 @@ class PreferenceFront extends FrontClassWithSpec(preferenceSpec) {
}
async getTraits() {
if (!this._traits) {
this._traits = await super.getTraits();
if (this._traits) {
return this._traits;
}
try {
this._traits = await this.getTraits();
} catch (e) {
// @backward-compat { version 82 } getTraits isn't supported on older server.
this._traits = {};
}
return this._traits;
}
}

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

@ -25,8 +25,15 @@ class StyleSheetsFront extends FrontClassWithSpec(styleSheetsSpec) {
if (this._traits) {
return this._traits;
}
const { traits } = await super.getTraits();
this._traits = traits;
try {
// @backward-compat { version 81 } getTraits isn't supported on older server.
const { traits } = await super.getTraits();
this._traits = traits;
} catch (e) {
this._traits = {};
}
return this._traits;
}
}

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

@ -12,6 +12,12 @@ const {
const { walkerSpec } = require("devtools/shared/specs/walker");
const { safeAsyncMethod } = require("devtools/shared/async-utils");
loader.lazyRequireGetter(
this,
"nodeConstants",
"devtools/shared/dom-node-constants"
);
/**
* Client side of the DOM walker.
*/
@ -322,6 +328,33 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
if ("numChildren" in change) {
targetFront._form.numChildren = change.numChildren;
}
} else if (change.type === "frameLoad") {
// @backward-compat { version 81 } The frameLoad mutation was removed in favor
// of the root-node resource.
// Nothing we need to do here, except verify that we don't have any
// document children, because we should have gotten a documentUnload
// first.
for (const child of targetFront.treeChildren()) {
if (child.nodeType === nodeConstants.DOCUMENT_NODE) {
console.warn(
"Got an unexpected frameLoad in the inspector, " +
"please file a bug on bugzilla.mozilla.org!"
);
console.trace();
}
}
} else if (change.type === "documentUnload") {
// @backward-compat { version 81 } The documentUnload mutation was removed in
// favor of the root-node resource.
// We try to give fronts instead of actorIDs, but these fronts need
// to be destroyed now.
emittedMutation.target = targetFront.actorID;
emittedMutation.targetParent = targetFront.parentNode();
// Release the document node and all of its children, even retained.
this._releaseFront(targetFront, true);
} else if (change.type === "shadowRootAttached") {
targetFront._form.isShadowHost = true;
} else if (change.type === "customElementDefined") {
@ -516,14 +549,14 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
}
_onRootNodeAvailable(rootNode) {
if (rootNode.isTopLevelDocument) {
if (this._isTopLevelRootNode(rootNode)) {
this.rootNode = rootNode;
this._rootNodePromiseResolve(this.rootNode);
}
}
_onRootNodeDestroyed(rootNode) {
if (rootNode.isTopLevelDocument) {
if (this._isTopLevelRootNode(rootNode)) {
this._rootNodePromise = new Promise(
r => (this._rootNodePromiseResolve = r)
);
@ -531,6 +564,16 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
}
}
_isTopLevelRootNode(rootNode) {
if (!rootNode.traits.supportsIsTopLevelDocument) {
// When `supportsIsTopLevelDocument` is false, a root-node resource is
// necessarily top level, so we can fallback to true.
return true;
}
return rootNode.isTopLevelDocument;
}
/**
* Start the element picker on the debuggee target.
* @param {Boolean} doFocus - Optionally focus the content area once the picker is
@ -540,8 +583,16 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
if (this._isPicking) {
return Promise.resolve();
}
this._isPicking = true;
// @backward-compat { version 80 } On older server, walker.pick doesn't exist.
if (!this.traits.supportsNodePicker) {
// parent is InspectorFront
return doFocus
? this.parentFront.highlighter.pickAndFocus()
: this.parentFront.highlighter.pick();
}
return super.pick(doFocus);
}
@ -552,8 +603,14 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
if (!this._isPicking) {
return Promise.resolve();
}
this._isPicking = false;
// @backward-compat { version 80 } On older server, walker.cancelPick doesn't exist.
if (!this.traits.supportsNodePicker) {
// parent is InspectorFront
return this.parentFront.highlighter.cancelPick();
}
return super.cancelPick();
}
}

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

@ -1407,8 +1407,21 @@ MarkupView.prototype = {
*/
_onWalkerMutations: function(mutations) {
for (const mutation of mutations) {
const type = mutation.type;
const target = mutation.target;
let type = mutation.type;
let target = mutation.target;
if (mutation.type === "documentUnload") {
// @backward-compat { version 81 } The documentUnload mutation was removed in
// favor of the root-node resource.
// Treat this as a childList change of the child (maybe the protocol
// should do this).
type = "childList";
target = mutation.targetParent;
if (!target) {
continue;
}
}
const container = this.getContainer(target);
if (!container) {

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

@ -365,6 +365,7 @@ ElementEditor.prototype = {
_createScrollableBadge: function() {
const isInteractive =
this.isOverflowDebuggingEnabled &&
this.node.walkerFront.traits.supportsOverflowDebugging2 &&
// Document elements cannot have interative scrollable badges since retrieval of their
// overflow causing elements is not supported.
!this.node.isDocumentElement;
@ -502,7 +503,10 @@ ElementEditor.prototype = {
* scrollable badge is active/inactive.
*/
updateOverflowHighlight: async function() {
if (!this.isOverflowDebuggingEnabled) {
if (
!this.isOverflowDebuggingEnabled ||
!this.node.walkerFront.traits.supportsOverflowDebugging2
) {
return;
}

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

@ -477,7 +477,21 @@ StyleEditorUI.prototype = {
const stylesheetsFront = await this.currentTarget.getFront(
"stylesheets"
);
stylesheetsFront.addStyleSheet(source, selectedFile.path);
const traits = await stylesheetsFront.getTraits();
if (traits.isFileNameSupported) {
// FF81+ addStyleSheet of StyleSheetsFront supports file name parameter.
stylesheetsFront.addStyleSheet(source, selectedFile.path);
} else {
const styleSheet = await stylesheetsFront.addStyleSheet(source);
styleSheet.isNew = true;
const editor = await this._addStyleSheet({ styleSheet });
if (editor) {
editor.savedFile = selectedFile;
}
// Just for testing purposes.
this.emit("test:editor-updated", editor);
}
}
);
};

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

@ -276,12 +276,16 @@ StyleSheetEditor.prototype = {
*/
async _getSourceTextAndPrettify() {
const styleSheetsFront = await this._getStyleSheetsFront();
const traits = await styleSheetsFront.getTraits();
let longStr = null;
if (this.styleSheet.isOriginalSource) {
// If the stylesheet is OriginalSource, we should get the texts from SourceMapService.
// So, for now, we use OriginalSource.getText() as it is.
longStr = await this.styleSheet.getText();
} else if (!traits.supportResourceRequests) {
// @backward-compat { version 81 } Older server don't support resource requests.
longStr = await this.styleSheet.getText();
} else {
longStr = await styleSheetsFront.getText(this.resourceId);
}
@ -552,7 +556,13 @@ StyleSheetEditor.prototype = {
*/
async toggleDisabled() {
const styleSheetsFront = await this._getStyleSheetsFront();
styleSheetsFront.toggleDisabled(this.resourceId).catch(console.error);
const traits = await styleSheetsFront.getTraits();
if (traits.supportResourceRequests) {
styleSheetsFront.toggleDisabled(this.resourceId).catch(console.error);
} else {
this.styleSheet.toggleDisabled().catch(console.error);
}
},
/**
@ -598,12 +608,17 @@ StyleSheetEditor.prototype = {
try {
const styleSheetsFront = await this._getStyleSheetsFront();
await styleSheetsFront.update(
this.resourceId,
this._state.text,
this.transitionsEnabled
);
const traits = await styleSheetsFront.getTraits();
if (traits.supportResourceRequests) {
await styleSheetsFront.update(
this.resourceId,
this._state.text,
this.transitionsEnabled
);
} else {
await this.styleSheet.update(this._state.text, this.transitionsEnabled);
}
// Clear any existing mappings from automatic CSS prettification
// because they were likely invalided by manually editing the stylesheet.
this._mappings = null;
@ -808,12 +823,18 @@ StyleSheetEditor.prototype = {
this._isUpdating = true;
const styleSheetsFront = await this._getStyleSheetsFront();
const traits = await styleSheetsFront.getTraits();
await styleSheetsFront.update(
this.resourceId,
text,
this.transitionsEnabled
);
if (traits.supportResourceRequests) {
await styleSheetsFront.update(
this.resourceId,
text,
this.transitionsEnabled
);
} else {
const relatedSheet = this.styleSheet.relatedStyleSheet;
await relatedSheet.update(text, this.transitionsEnabled);
}
}, this.markLinkedFileBroken);
},

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

@ -205,7 +205,9 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
this.rawNode.ownerDocument &&
this.rawNode.ownerDocument.contentType === "text/html",
hasEventListeners: this._hasEventListeners,
traits: {},
traits: {
supportsIsTopLevelDocument: true,
},
};
if (this.isDocumentElement()) {

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

@ -320,7 +320,12 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
return {
actor: this.actorID,
root: this.rootNode.form(),
traits: {},
traits: {
// @backward-compat { version 80 } Walker implements node picker
supportsNodePicker: true,
// @backward-compat { version 83 } Walker implements overflow debugging support
supportsOverflowDebugging2: true,
},
};
},

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

@ -178,6 +178,8 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, {
// expected support of font-stretch at CSS Fonts Level 4.
fontWeightLevel4:
CSS.supports("font-weight: 1") && CSS.supports("font-stretch: 100%"),
// @backward-compat { version 80 }
getAttributesInOwnerDocument: true,
},
};
},

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

@ -33,7 +33,12 @@ var PreferenceActor = protocol.ActorClassWithSpec(preferenceSpec, {
// specific preferences are fixed on the server or if the client should set
// default values for them. See the about:debugging module
// runtime-default-preferences.js
return {};
return {
// @backward-compat { version 81 } Fixed on the server by Bug 1659866.
overflowDebuggingPref: true,
// @backward-compat { version 82 } Fixed on the server by Bug 1662058.
targetBrowsersPref: true,
};
},
getBoolPref: function(name) {

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

@ -55,7 +55,12 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
getTraits() {
return {
traits: {},
traits: {
// @backward-compat { version 81 } addStyleSheet now supports file name parameter.
isFileNameSupported: true,
// @backward-compat { version 81 } resource requesting supports.
supportResourceRequests: true,
},
};
},

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

@ -3,53 +3,29 @@
"use strict";
// Test that StyleSheetsActor.getText handles empty text correctly.
// Test that StyleSheetActor.getText handles empty text correctly.
const CSS_CONTENT = "body { background-color: #f06; }";
const TEST_URI = `data:text/html;charset=utf-8,<style>${encodeURIComponent(
CSS_CONTENT
)}</style>`;
const CONTENT = "<style>body { background-color: #f06; }</style>";
const TEST_URI = "data:text/html;charset=utf-8," + encodeURIComponent(CONTENT);
add_task(async function() {
const target = await addTabTarget(TEST_URI);
const front = await target.getFront("stylesheets");
ok(front, "The StyleSheetsFront was created.");
const {
ResourceWatcher,
} = require("devtools/shared/resources/resource-watcher");
const { TargetList } = require("devtools/shared/resources/target-list");
const targetList = new TargetList(target.client.mainRoot, target);
await targetList.startListening();
const resourceWatcher = new ResourceWatcher(targetList);
const styleSheetsFront = await target.getFront("stylesheets");
ok(styleSheetsFront, "The StyleSheetsFront was created.");
const sheets = [];
await resourceWatcher.watchResources([ResourceWatcher.TYPES.STYLESHEET], {
onAvailable: resources => sheets.push(...resources),
});
is(sheets.length, 1, "watchResources returned the correct number of sheets");
const { resourceId } = sheets[0];
const sheets = await front.getStyleSheets();
ok(sheets, "getStyleSheets() succeeded");
is(
await getStyleSheetText(styleSheetsFront, resourceId),
CSS_CONTENT,
"The stylesheet has expected initial text"
);
info("Update stylesheet content via the styleSheetsFront");
await styleSheetsFront.update(resourceId, "", false);
is(
await getStyleSheetText(styleSheetsFront, resourceId),
"",
"Stylesheet is now empty, as expected"
sheets.length,
1,
"getStyleSheets() returned the correct number of sheets"
);
const sheet = sheets[0];
await sheet.update("", false);
const longStr = await sheet.getText();
const source = await longStr.string();
is(source, "", "text is empty");
await target.destroy();
});
async function getStyleSheetText(styleSheetsFront, resourceId) {
const longStringFront = await styleSheetsFront.getText(resourceId);
return longStringFront.string();
}

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

@ -898,6 +898,8 @@ const ResourceTransformers = {
.ERROR_MESSAGE]: require("devtools/shared/resources/transformers/error-messages"),
[ResourceWatcher.TYPES
.LOCAL_STORAGE]: require("devtools/shared/resources/transformers/storage-local-storage.js"),
[ResourceWatcher.TYPES
.ROOT_NODE]: require("devtools/shared/resources/transformers/root-node"),
[ResourceWatcher.TYPES
.SESSION_STORAGE]: require("devtools/shared/resources/transformers/storage-session-storage.js"),
[ResourceWatcher.TYPES

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

@ -6,6 +6,7 @@ DevToolsModules(
"console-messages.js",
"error-messages.js",
"network-events.js",
"root-node.js",
"storage-local-storage.js",
"storage-session-storage.js",
)

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

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* Transformer for the root node resource.
*
* @param {NodeFront} resource
* @param {TargetFront} targetFront
* @return {NodeFront} the updated resource
*/
module.exports = function({ resource, targetFront }) {
if (!resource.traits.supportsIsTopLevelDocument) {
// When `supportsIsTopLevelDocument` is false, a root-node resource is
// necessarily top level, se we can fallback to true.
resource.isTopLevelDocument = true;
}
return resource;
};

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

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { RetVal, generateActorSpec } = require("devtools/shared/protocol");
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
const workerDescriptorSpec = generateActorSpec({
typeName: "workerDescriptor",
@ -17,6 +17,13 @@ const workerDescriptorSpec = generateActorSpec({
request: {},
response: RetVal("json"),
},
// @backward-compat { version 83 } We don't use `connect` anymore.
connect: {
request: {
options: Arg(0, "json"),
},
response: RetVal("json"),
},
getTarget: {
request: {},
response: RetVal("json"),

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

@ -36,12 +36,29 @@ const styleSheetSpec = generateActorSpec({
},
methods: {
// @backward-compat { version 81 }
toggleDisabled: {
response: { disabled: RetVal("boolean") },
},
// @backward-compat { version 81 }
getText: {
response: {
text: RetVal("longstring"),
},
},
getMediaRules: {
request: {},
response: {
mediaRules: RetVal("nullable:array:mediarule"),
},
},
// @backward-compat { version 81 }
update: {
request: {
text: Arg(0, "string"),
transition: Arg(1, "boolean"),
},
},
},
});