зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1628044 - Remove obsolete initCssProperties() helper and cleanup tests; r=jdescottes
Depends on D70071 After changes in D70071, the `CSSProperties` object is retrieved from the `CSSPropertiesFront`. The `initCssProperties()` method is no longer required. It is only used in tests. This patch removes the leftover callsites for `initCssProperties()` from tests and the method implementation itself. Differential Revision: https://phabricator.services.mozilla.com/D71560
This commit is contained in:
Родитель
5041fb4bbd
Коммит
17fd76e771
|
@ -44,8 +44,6 @@ var IS_VARIABLE_TOKEN = new RegExp(
|
|||
"i"
|
||||
);
|
||||
|
||||
var cachedCssProperties = new WeakMap();
|
||||
|
||||
/**
|
||||
* The CssProperties front provides a mechanism to have a one-time asynchronous
|
||||
* load of a CSS properties database. This is then fed into the CssProperties
|
||||
|
@ -218,32 +216,6 @@ function hasFeature(featureSet, feature) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CssProperties object with a fully loaded CSS database. The
|
||||
* CssProperties interface can be queried synchronously, but the initialization
|
||||
* is potentially async and should be handled up-front when the tool is created.
|
||||
*
|
||||
* The front is returned only with this function so that it can be destroyed
|
||||
* once the toolbox is destroyed.
|
||||
*
|
||||
* @param {Toolbox} The current toolbox.
|
||||
* @returns {Promise} Resolves to {cssProperties, cssPropertiesFront}.
|
||||
*/
|
||||
const initCssProperties = async function(toolbox) {
|
||||
const client = toolbox.target.client;
|
||||
if (cachedCssProperties.has(client)) {
|
||||
return cachedCssProperties.get(client);
|
||||
}
|
||||
|
||||
// Get the list dynamically if the cssProperties actor exists.
|
||||
const front = await toolbox.target.getFront("cssProperties");
|
||||
const db = await front.getCSSDatabase();
|
||||
|
||||
const cssProperties = new CssProperties(normalizeCssData(db));
|
||||
cachedCssProperties.set(client, { cssProperties, front });
|
||||
return { cssProperties, front };
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a client-side CssProperties. This is useful for dependencies in tests, or parts
|
||||
* of the codebase that don't particularly need to match every known CSS property on
|
||||
|
@ -345,9 +317,7 @@ function reattachCssColorValues(db) {
|
|||
|
||||
module.exports = {
|
||||
CssPropertiesFront,
|
||||
CssProperties,
|
||||
getClientCssProperties,
|
||||
initCssProperties,
|
||||
isCssVariable,
|
||||
};
|
||||
registerFront(CssPropertiesFront);
|
||||
|
|
|
@ -119,6 +119,10 @@ function StyleEditorUI(toolbox, panelDoc, cssProperties) {
|
|||
}
|
||||
|
||||
StyleEditorUI.prototype = {
|
||||
get cssProperties() {
|
||||
return this._cssProperties;
|
||||
},
|
||||
|
||||
get currentTarget() {
|
||||
return this._toolbox.targetList.targetFront;
|
||||
},
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
const TESTCASE_URI = TEST_BASE_HTTP + "autocomplete.html";
|
||||
const MAX_SUGGESTIONS = 15;
|
||||
|
||||
const { initCssProperties } = require("devtools/client/fronts/css-properties");
|
||||
|
||||
// Test cases to test that autocompletion works correctly when enabled.
|
||||
// Format:
|
||||
// [
|
||||
|
@ -129,7 +127,7 @@ function getTestCases(cssProperties) {
|
|||
|
||||
add_task(async function() {
|
||||
const { panel, ui } = await openStyleEditorForURL(TESTCASE_URI);
|
||||
const { cssProperties } = await initCssProperties(panel._toolbox);
|
||||
const { cssProperties } = ui;
|
||||
const testCases = getTestCases(cssProperties);
|
||||
|
||||
await ui.selectStyleSheet(ui.editors[1].styleSheet);
|
||||
|
|
|
@ -13,27 +13,15 @@ Bug 1265798 - Replace inIDOMUtils.cssPropertyIsShorthand
|
|||
"use strict";
|
||||
|
||||
window.onload = function() {
|
||||
const { initCssProperties } = require("devtools/client/fronts/css-properties");
|
||||
|
||||
function toSortedString(array) {
|
||||
return JSON.stringify(array.sort());
|
||||
}
|
||||
|
||||
// Return some mocked values for a tab. Override hasActor with the
|
||||
// options passed into the test. A second property is used
|
||||
// during these tests: `win` for css-properties.js's getClientBrowserVersion.
|
||||
async function getTabProperties(url, useActor) {
|
||||
const { target, win } = await attachURL(url);
|
||||
target.hasActor = () => useActor;
|
||||
return { target, win };
|
||||
}
|
||||
|
||||
const runCssPropertiesTests = async function(url, useActor) {
|
||||
info(`Opening two tabs ${useActor ? "with" : "without"} CssPropertiesActor support.`);
|
||||
|
||||
const runCssPropertiesTests = async function(url) {
|
||||
info(`Opening tab with CssPropertiesActor support.`);
|
||||
// Open a new tab. The only property we are interested in is `target`.
|
||||
const tab = await getTabProperties(url, useActor);
|
||||
const { cssProperties } = await initCssProperties(tab);
|
||||
const { target } = await attachURL(url);
|
||||
const { cssProperties } = await target.getFront("cssProperties");
|
||||
|
||||
ok(cssProperties.isKnown("border"),
|
||||
"The `border` shorthand property is known.");
|
||||
|
@ -67,8 +55,7 @@ window.onload = function() {
|
|||
|
||||
addAsyncTest(async function setup() {
|
||||
const url = document.getElementById("cssProperties").href;
|
||||
await runCssPropertiesTests(url, true);
|
||||
await runCssPropertiesTests(url, false);
|
||||
await runCssPropertiesTests(url);
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче