mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1661625: Get stylesheets traits if needed. r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D89339
This commit is contained in:
parent
7d48c81098
commit
5ee0f8ed93
@ -417,16 +417,6 @@ class SourceMapURLService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to wait for the full retrieval of JS Sources and stylesheets.
|
||||
* This function is especially useful for tests in order to avoid closing
|
||||
* the toolbox with pending requests.
|
||||
* This may return null if no source are being mapped.
|
||||
*/
|
||||
waitForPendingSources() {
|
||||
return this._sourcesLoading;
|
||||
}
|
||||
|
||||
_ensureAllSourcesPopulated() {
|
||||
if (!this._prefValue) {
|
||||
return null;
|
||||
|
@ -153,7 +153,11 @@ class StyleSheetsFront extends FrontClassWithSpec(styleSheetsSpec) {
|
||||
this.formAttributeName = "styleSheetsActor";
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
async getTraits() {
|
||||
if (this._traits) {
|
||||
return this._traits;
|
||||
}
|
||||
|
||||
try {
|
||||
// FF81+ getTraits() is supported.
|
||||
const { traits } = await super.getTraits();
|
||||
@ -161,9 +165,7 @@ class StyleSheetsFront extends FrontClassWithSpec(styleSheetsSpec) {
|
||||
} catch (e) {
|
||||
this._traits = {};
|
||||
}
|
||||
}
|
||||
|
||||
get traits() {
|
||||
return this._traits;
|
||||
}
|
||||
}
|
||||
|
@ -314,13 +314,6 @@ function initNetMonitor(url, { requestCount, enableCache = false }) {
|
||||
const toolbox = await gDevTools.showToolbox(target, "netmonitor");
|
||||
info("Network monitor pane shown successfully.");
|
||||
|
||||
// There are tests of netmonitor that call source-map-url-service and load the source
|
||||
// codes and stylesheets. However, the processing of the request may have not been
|
||||
// finished when closing the windows and related toolboxes, it may cause test failure.
|
||||
// Hence, we call it explicitly, then wait for finishing the pending requests.
|
||||
toolbox.sourceMapURLService._ensureAllSourcesPopulated();
|
||||
await toolbox.sourceMapURLService.waitForPendingSources();
|
||||
|
||||
const monitor = toolbox.getCurrentPanel();
|
||||
|
||||
startNetworkEventUpdateObserver(monitor.panelWin);
|
||||
|
@ -478,7 +478,8 @@ StyleEditorUI.prototype = {
|
||||
"stylesheets"
|
||||
);
|
||||
|
||||
if (stylesheetsFront.traits.isFileNameSupported) {
|
||||
const traits = await stylesheetsFront.getTraits();
|
||||
if (traits.isFileNameSupported) {
|
||||
// FF81+ addStyleSheet of StyleSheetsFront supports file name parameter.
|
||||
stylesheetsFront.addStyleSheet(source, selectedFile.path);
|
||||
} else {
|
||||
|
@ -276,13 +276,14 @@ 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 (!styleSheetsFront.traits.supportResourceRequests) {
|
||||
} else if (!traits.supportResourceRequests) {
|
||||
// Backward compat, can be removed when FF 81 hits release.
|
||||
longStr = await this.styleSheet.getText();
|
||||
} else {
|
||||
@ -562,7 +563,9 @@ StyleSheetEditor.prototype = {
|
||||
*/
|
||||
async toggleDisabled() {
|
||||
const styleSheetsFront = await this._getStyleSheetsFront();
|
||||
if (styleSheetsFront.traits.supportResourceRequests) {
|
||||
const traits = await styleSheetsFront.getTraits();
|
||||
|
||||
if (traits.supportResourceRequests) {
|
||||
styleSheetsFront.toggleDisabled(this.resourceId).catch(console.error);
|
||||
} else {
|
||||
this.styleSheet.toggleDisabled().catch(console.error);
|
||||
@ -612,7 +615,9 @@ StyleSheetEditor.prototype = {
|
||||
|
||||
try {
|
||||
const styleSheetsFront = await this._getStyleSheetsFront();
|
||||
if (styleSheetsFront.traits.supportResourceRequests) {
|
||||
const traits = await styleSheetsFront.getTraits();
|
||||
|
||||
if (traits.supportResourceRequests) {
|
||||
await styleSheetsFront.update(
|
||||
this.resourceId,
|
||||
this._state.text,
|
||||
@ -827,7 +832,9 @@ StyleSheetEditor.prototype = {
|
||||
this._isUpdating = true;
|
||||
|
||||
const styleSheetsFront = await this._getStyleSheetsFront();
|
||||
if (styleSheetsFront.traits.supportResourceRequests) {
|
||||
const traits = await styleSheetsFront.getTraits();
|
||||
|
||||
if (traits.supportResourceRequests) {
|
||||
await styleSheetsFront.update(
|
||||
this.resourceId,
|
||||
text,
|
||||
|
@ -849,14 +849,6 @@ async function openNetMonitor(tab) {
|
||||
async function openConsole(tab) {
|
||||
const target = await TargetFactory.forTab(tab || gBrowser.selectedTab);
|
||||
const toolbox = await gDevTools.showToolbox(target, "webconsole");
|
||||
|
||||
// Approximately half of webconsole tests call source-map-url-service and load the source
|
||||
// codes and stylesheets. However, the processing of the request may have not been
|
||||
// finished when closing the windows and related toolboxes, it may cause test failure.
|
||||
// Hence, we call it explicitly, then wait for finishing the pending requests.
|
||||
toolbox.sourceMapURLService._ensureAllSourcesPopulated();
|
||||
await toolbox.sourceMapURLService.waitForPendingSources();
|
||||
|
||||
return toolbox.getCurrentPanel().hud;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user