Bug 1000716 - Intermittent race condition in markupview/test/browser_markupview_mutation_02.js. r=miker, a=test-only
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 11 Aug 2014 04:43:00 -0400
changeset 217464 9f66c08b991a33256afd9abbcb1454fca1f2dc77
parent 217463 23226274b981ce16ab71875d05828da86307a76f
child 217465 0c1e35b6c22a77b28786bc98508a6a59f84fedae
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiker, test-only
bugs1000716
milestone33.0a2
Bug 1000716 - Intermittent race condition in markupview/test/browser_markupview_mutation_02.js. r=miker, a=test-only
browser/devtools/markupview/markup-view.js
browser/devtools/markupview/test/browser_markupview_mutation_02.js
--- a/browser/devtools/markupview/markup-view.js
+++ b/browser/devtools/markupview/markup-view.js
@@ -8,17 +8,16 @@ const {Cc, Cu, Ci} = require("chrome");
 
 // Page size for pageup/pagedown
 const PAGE_SIZE = 10;
 const PREVIEW_AREA = 700;
 const DEFAULT_MAX_CHILDREN = 100;
 const COLLAPSE_ATTRIBUTE_LENGTH = 120;
 const COLLAPSE_DATA_URL_REGEX = /^data.+base64/;
 const COLLAPSE_DATA_URL_LENGTH = 60;
-const CONTAINER_FLASHING_DURATION = 500;
 const NEW_SELECTION_HIGHLIGHTER_TIMER = 1000;
 
 const {UndoStack} = require("devtools/shared/undo");
 const {editableField, InplaceEditor} = require("devtools/shared/inplace-editor");
 const {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
 const {HTMLEditor} = require("devtools/markupview/html-editor");
 const promise = require("devtools/toolkit/deprecated-sync-thenables");
 const {Tooltip} = require("devtools/shared/widgets/Tooltip");
@@ -107,16 +106,21 @@ function MarkupView(aInspector, aFrame, 
   this._initHighlighter();
 
   EventEmitter.decorate(this);
 }
 
 exports.MarkupView = MarkupView;
 
 MarkupView.prototype = {
+  /**
+   * How long does a node flash when it mutates (in ms).
+   */
+  CONTAINER_FLASHING_DURATION: 500,
+
   _selectedContainer: null,
 
   _initTooltips: function() {
     this.tooltip = new Tooltip(this._inspector.panelDoc);
     this._makeTooltipPersistent(false);
 
     this._elt.addEventListener("click", this._onMouseClick, false);
   },
@@ -1573,17 +1577,17 @@ MarkupContainer.prototype = {
       let contentWin = this.markup._frame.contentWindow;
       this.flashed = true;
       if (this._flashMutationTimer) {
         contentWin.clearTimeout(this._flashMutationTimer);
         this._flashMutationTimer = null;
       }
       this._flashMutationTimer = contentWin.setTimeout(() => {
         this.flashed = false;
-      }, CONTAINER_FLASHING_DURATION);
+      }, this.markup.CONTAINER_FLASHING_DURATION);
     }
   },
 
   set flashed(aValue) {
     if (aValue) {
       // Make sure the animation class is not here
       this.tagState.classList.remove("flash-out");
 
--- a/browser/devtools/markupview/test/browser_markupview_mutation_02.js
+++ b/browser/devtools/markupview/test/browser_markupview_mutation_02.js
@@ -50,16 +50,20 @@ const TEST_DATA = [{
   mutate: (doc, rootNode) => {
     rootNode.removeAttribute("class");
   }
 }];
 
 let test = asyncTest(function*() {
   let {inspector} = yield addTab(TEST_URL).then(openInspector);
 
+  // Make sure mutated nodes flash for a very long time so we can more easily
+  // assert they do
+  inspector.markup.CONTAINER_FLASHING_DURATION = 1000 * 60 * 60;
+
   info("Getting the <ul.list> root node to test mutations on");
   let rootNode = getNode(".list");
   let rootNodeFront = yield getNodeFront(".list", inspector);
 
   info("Selecting the last element of the root node before starting");
   yield selectNode(".list .item:nth-child(2)", inspector);
 
   for (let {mutate, flashedNode, desc} of TEST_DATA) {
@@ -83,9 +87,14 @@ let test = asyncTest(function*() {
   }
 });
 
 function* assertNodeFlashing(nodeFront, inspector) {
   let container = getContainerForNodeFront(nodeFront, inspector);
   ok(container, "Markup container for node found");
   ok(container.tagState.classList.contains("theme-bg-contrast"),
     "Markup container for node is flashing");
+
+  // Clear the mutation flashing timeout now that we checked the node was flashing
+  let markup = inspector.markup;
+  markup._frame.contentWindow.clearTimeout(container._flashMutationTimer);
+  container._flashMutationTimer = null;
 }