Bug 1488377 - remove outdated backwards compat code; r=ochameau
authoryulia <ystartsev@mozilla.com>
Wed, 10 Oct 2018 15:37:11 +0000
changeset 496429 affa0f9b807d7cc49ed48e3677a89a98db55cb60
parent 496428 b7fc0fb0f0e26404469cdddeef541b8154835ec0
child 496430 4604dcda85aa20d4694df3c91b7f105a1b62b8e2
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1488377
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488377 - remove outdated backwards compat code; r=ochameau Depends on D7886 Differential Revision: https://phabricator.services.mozilla.com/D7994
devtools/client/inspector/shared/test/browser_styleinspector_output-parser.js
devtools/client/shared/test/browser_outputparser.js
devtools/shared/fronts/css-properties.js
--- a/devtools/client/inspector/shared/test/browser_styleinspector_output-parser.js
+++ b/devtools/client/inspector/shared/test/browser_styleinspector_output-parser.js
@@ -5,16 +5,17 @@
 "use strict";
 
 // Test expected outputs of the output-parser's parseCssProperty function.
 
 // This is more of a unit test than a mochitest-browser test, but can't be
 // tested with an xpcshell test as the output-parser requires the DOM to work.
 
 const OutputParser = require("devtools/client/shared/output-parser");
+const { CSS_PROPERTIES_DB} = require("devtools/shared/css/properties-db");
 const {initCssProperties, getCssProperties} = require("devtools/shared/fronts/css-properties");
 
 const COLOR_CLASS = "color-class";
 const URL_CLASS = "url-class";
 const CUBIC_BEZIER_CLASS = "bezier-class";
 const ANGLE_CLASS = "angle-class";
 
 const TEST_DATA = [
@@ -289,17 +290,23 @@ const TEST_DATA = [
     test: fragment => {
       is(fragment.textContent, "rgb(255, var(--g-value, 0), 192)");
     }
   }
 ];
 
 add_task(async function() {
   // Mock the toolbox that initCssProperties expect so we get the fallback css properties.
-  const toolbox = {target: {client: {}, hasActor: () => false}};
+  const toolbox = {
+    target: {
+      client: {},
+      hasActor: () => false,
+      getFront: typeName => ({getCSSDatabase: () => CSS_PROPERTIES_DB})
+    }
+  };
   await initCssProperties(toolbox);
   const cssProperties = getCssProperties(toolbox);
 
   const parser = new OutputParser(document, cssProperties);
   for (let i = 0; i < TEST_DATA.length; i++) {
     const data = TEST_DATA[i];
     info("Output-parser test data " + i + ". {" + data.name + " : " +
       data.value + ";}");
--- a/devtools/client/shared/test/browser_outputparser.js
+++ b/devtools/client/shared/test/browser_outputparser.js
@@ -1,29 +1,36 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const OutputParser = require("devtools/client/shared/output-parser");
 const {initCssProperties, getCssProperties} = require("devtools/shared/fronts/css-properties");
+const { CSS_PROPERTIES_DB} = require("devtools/shared/css/properties-db");
 const CSS_SHAPES_ENABLED_PREF = "devtools.inspector.shapesHighlighter.enabled";
 
 add_task(async function() {
   await addTab("about:blank");
   await performTest();
   gBrowser.removeCurrentTab();
 });
 
 async function performTest() {
   const [host, , doc] = await createHost("bottom", "data:text/html," +
     "<h1>browser_outputParser.js</h1><div></div>");
 
   // Mock the toolbox that initCssProperties expect so we get the fallback css properties.
-  const toolbox = {target: {client: {}, hasActor: () => false}};
+  const toolbox = {
+    target: {
+      client: {},
+      hasActor: () => false,
+      getFront: typeName => ({getCSSDatabase: () => CSS_PROPERTIES_DB})
+    }
+  };
   await initCssProperties(toolbox);
   const cssProperties = getCssProperties(toolbox);
 
   const parser = new OutputParser(doc, cssProperties);
   testParseCssProperty(doc, parser);
   testParseCssVar(doc, parser);
   testParseURL(doc, parser);
   testParseFilter(doc, parser);
--- a/devtools/shared/fronts/css-properties.js
+++ b/devtools/shared/fronts/css-properties.js
@@ -228,27 +228,19 @@ CssProperties.prototype = {
  * @returns {Promise} Resolves to {cssProperties, cssPropertiesFront}.
  */
 const initCssProperties = async function(toolbox) {
   const client = toolbox.target.client;
   if (cachedCssProperties.has(client)) {
     return cachedCssProperties.get(client);
   }
 
-  let db, front;
-
   // Get the list dynamically if the cssProperties actor exists.
-  if (toolbox.target.hasActor("cssProperties")) {
-    front = toolbox.target.getFront("cssProperties");
-    db = await front.getCSSDatabase();
-  } else {
-    // The target does not support this actor, so require a static list of supported
-    // properties.
-    db = CSS_PROPERTIES_DB;
-  }
+  const front = toolbox.target.getFront("cssProperties");
+  const db = await front.getCSSDatabase();
 
   const cssProperties = new CssProperties(normalizeCssData(db));
   cachedCssProperties.set(client, {cssProperties, front});
   return {cssProperties, front};
 };
 
 /**
  * Synchronously get a cached and initialized CssProperties.