Bug 1246677 - 4 - Stop using content.getComputedStyle in ruleview tests draft
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 08 Feb 2016 22:08:10 +0100
changeset 330656 a30d6d613fe5ca45780232ddd9cb1235cb4ae059
parent 330655 60b5facfb092907f1746cf3f029a810861d9ab3d
child 330657 2647379d01e6cb1f21e2c3a87edad81cabbf1b9c
push id10801
push userpbrosset@mozilla.com
push dateFri, 12 Feb 2016 13:33:31 +0000
bugs1246677
milestone47.0a1
Bug 1246677 - 4 - Stop using content.getComputedStyle in ruleview tests MozReview-Commit-ID: 6BYYYLwO2O5
devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js
devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js
devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js
devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js
devtools/client/inspector/rules/test/browser_rules_eyedropper.js
devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js
--- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js
+++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-commit-on-ENTER.js
@@ -46,16 +46,16 @@ function* testPressingEnterCommitsChange
 
   let onModified = ruleView.once("ruleview-changed");
   let spectrum = yield cPicker.spectrum;
   let onHidden = cPicker.tooltip.once("hidden");
   EventUtils.sendKey("RETURN", spectrum.element.ownerDocument.defaultView);
   yield onHidden;
   yield onModified;
 
-  is(content.getComputedStyle(content.document.body).borderLeftColor,
+  is((yield getComputedStyleProperty("body", null, "border-left-color")),
     "rgba(0, 255, 0, 0.5)", "The element's border was kept after RETURN");
   is(swatch.style.backgroundColor, "rgba(0, 255, 0, 0.5)",
     "The color swatch's background was kept after RETURN");
   is(getRuleViewProperty(ruleView, "body", "border").valueSpan.textContent,
     "2em solid rgba(0, 255, 0, 0.5)",
     "The text of the border css property was kept after RETURN");
 }
--- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js
+++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-edit-gradient.js
@@ -62,15 +62,15 @@ function* testPickingNewColor(view) {
     name: "background-image",
     value: "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, rgb(0, 0, 0) 100%)"
   };
   yield simulateColorPickerChange(view, cPicker, [1, 1, 1, 1], change);
 
   is(swatchEl.style.backgroundColor, "rgb(1, 1, 1)",
     "The color swatch's background was updated");
   is(colorEl.textContent, "#010101", "The color text was updated");
-  is(content.getComputedStyle(content.document.body).backgroundImage,
+  is((yield getComputedStyleProperty("body", null, "background-image")),
     "linear-gradient(to left, rgb(1, 1, 1) 25%, rgb(51, 51, 51) 95%, " +
       "rgb(0, 0, 0) 100%)",
     "The gradient has been updated correctly");
 
   yield hideTooltipAndWaitForRuleViewChanged(cPicker, view);
 }
--- a/devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js
+++ b/devtools/client/inspector/rules/test/browser_rules_colorpicker-multiple-changes.js
@@ -113,12 +113,12 @@ function* testOverriddenMultipleColorCha
     {rgba: [200, 200, 200, 1], computed: "rgb(200, 200, 200)"}
   ];
   for (let {rgba, computed} of colors) {
     yield simulateColorPickerChange(ruleView, picker, rgba, {
       selector: "body",
       name: "color",
       value: computed
     });
-    is(content.getComputedStyle(content.document.querySelector("p")).color,
+    is((yield getComputedStyleProperty("p", null, "color")),
       "rgb(200, 200, 200)", "The color of the P tag is still correct");
   }
 }
--- a/devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js
+++ b/devtools/client/inspector/rules/test/browser_rules_cubicbezier-commit-on-ENTER.js
@@ -35,29 +35,30 @@ function* testPressingEnterCommitsChange
   yield onShown;
 
   let widget = yield bezierTooltip.widget;
   info("Simulating a change of curve in the widget");
   widget.coordinates = [0.1, 2, 0.9, -1];
   let expected = "cubic-bezier(0.1, 2, 0.9, -1)";
 
   yield waitForSuccess(function*() {
-    return content.getComputedStyle(content.document.body)
-                  .transitionTimingFunction === expected;
+    let func = yield getComputedStyleProperty("body", null,
+                                              "transition-timing-function");
+    return func === expected;
   }, "Waiting for the change to be previewed on the element");
 
   ok(getRuleViewProperty(ruleView, "body", "transition").valueSpan.textContent
     .indexOf("cubic-bezier(") !== -1,
     "The text of the timing-function was updated");
 
   info("Sending RETURN key within the tooltip document");
   // Pressing RETURN ends up doing 2 rule-view updates, one for the preview and
   // one for the commit when the tooltip closes.
   let onRuleViewChanged = waitForNEvents(ruleView, "ruleview-changed", 2);
   EventUtils.sendKey("RETURN", widget.parent.ownerDocument.defaultView);
   yield onRuleViewChanged;
 
-  is(content.getComputedStyle(content.document.body).transitionTimingFunction,
+  is((yield getComputedStyleProperty("body", null, "transition-timing-function")),
     expected, "The element's timing-function was kept after RETURN");
   ok(getRuleViewProperty(ruleView, "body", "transition").valueSpan.textContent
     .indexOf("cubic-bezier(") !== -1,
     "The text of the timing-function was kept after RETURN");
 }
--- a/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
+++ b/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
@@ -98,18 +98,17 @@ function* testSelect(view, swatch, dropp
   inspectPage(dropper);
 
   yield onDestroyed;
   yield onRuleViewChanged;
 
   let color = swatch.style.backgroundColor;
   is(color, EXPECTED_COLOR, "swatch changed colors");
 
-  let element = content.document.querySelector("div");
-  is(content.window.getComputedStyle(element).backgroundColor,
+  is((yield getComputedStyleProperty("div", null, "background-color")),
      EXPECTED_COLOR,
      "div's color set to body color after dropper");
 }
 
 function clearTelemetry() {
   for (let histogramId in EXPECTED_TELEMETRY) {
     let histogram = Services.telemetry.getHistogramById(histogramId);
     histogram.clear();
--- a/devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js
+++ b/devtools/client/inspector/rules/test/browser_rules_filtereditor-commit-on-ENTER.js
@@ -35,12 +35,11 @@ add_task(function*() {
   ok(true, "Changes previewed on the element");
 
   info("Press RETURN to commit changes");
   // Pressing return in the cssfilter tooltip triggeres 2 ruleview-changed
   onRuleViewChanged = waitForNEvents(view, "ruleview-changed", 2);
   EventUtils.sendKey("RETURN", widget.styleWindow);
   yield onRuleViewChanged;
 
-  const computed = content.getComputedStyle(content.document.body);
-  is(computed.filter, "blur(2px)",
+  is((yield getComputedStyleProperty("body", null, "filter")), "blur(2px)",
      "The elemenet's filter was kept after RETURN");
 });