Closed
Bug 914861
Opened 11 years ago
Closed 11 years ago
browser_toolbox_options.js times out when a tool in defaultTools is disabled by default
Categories
(DevTools :: Framework, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 27
People
(Reporter: rjacob, Assigned: rjacob)
References
Details
Attachments
(1 file, 3 obsolete files)
10.81 KB,
patch
|
Details | Diff | Splinter Review |
browser_toolbox_options assumes that all tools are enabled by default. The toggleTools function adds a listener for the "tool-unregistered" event, but the synthesized click that follows triggers a "tool-registered" event for tools which are disabled by default. The test times out waiting for the "tool-unregistered" event, and the output doesn't do much to indicate what the actual problem is.
The test should either explicitly test that all default tools are enabled at the beginning of the test, or it should not depend on the default enablement state of the default tools.
Assignee | ||
Comment 1•11 years ago
|
||
Makes the test not dependent on the initial state of the tool prefs.
Attachment #804736 -
Flags: review?(rcampbell)
Assignee | ||
Comment 2•11 years ago
|
||
Comment 3•11 years ago
|
||
Comment on attachment 804736 [details] [diff] [review]
Patch
Review of attachment 804736 [details] [diff] [review]:
-----------------------------------------------------------------
::: browser/devtools/framework/test/browser_toolbox_options.js
@@ +1,4 @@
> /* Any copyright is dedicated to the Public Domain.
> * http://creativecommons.org/publicdomain/zero/1.0/ */
>
> +let doc = null, toolbox = null, panelWin = null, index = 0, prefValues = [], prefNodes = [], toggleInReverse = false;
could you break these up a bit please? That line's gotten ridiculous.
@@ +89,1 @@
> prefNodes = prefNodes.sort(() => Math.random() > 0.5 ? 1: -1);
no.
@@ +117,5 @@
> + toggleInReverse ? index-- : index++;
> + if (index === prefNodes.length) {
> + toggleInReverse = true;
> + index--;
> + }
I really don't like what this test is doing. It's impossible to follow having state in this global index variable.
I'm bailing out of the review to reread why you're doing this.
Attachment #804736 -
Flags: review?(rcampbell)
Comment 4•11 years ago
|
||
yeah, I don't like adding randomness to our unittests. I think I'd like something deterministic here.
Assignee | ||
Comment 5•11 years ago
|
||
The randomness was already there (bug 915939). I just reworded the comment.
Benvie, anton, and I talked with Optimizer about it on IRC. The point of randomizing the order of toggling the tools is to ensure that when tools are removed or added, their toolbox tab is removed or re-added in sorted order.
So, it's testing this code: http://mxr.mozilla.org/mozilla-central/source/browser/devtools/framework/toolbox.js#535
The randomness isn't a good solution--I'm writing a version of this test that just tests edge cases instead.
Assignee | ||
Comment 6•11 years ago
|
||
Since this test and I are such good friends now, I tried to resolve both issues and make the test easier to understand. I removed most of the global state and used promises to (hopefully) make the test easier to follow.
Instead of disabling and re-enabling all the tools in a randomized order, the test now tries to test edge cases (adding a toolbox tab when no tabs are present; adding a tab to the beginning, middle, and end of the tab list). This should catch most failures that the randomized test could have caught.
Attachment #804736 -
Attachment is obsolete: true
Attachment #810099 -
Flags: feedback?(rcampbell)
Assignee | ||
Comment 7•11 years ago
|
||
Assignee | ||
Updated•11 years ago
|
Attachment #810099 -
Flags: feedback?(rcampbell) → review?(rcampbell)
Comment 8•11 years ago
|
||
Comment on attachment 810099 [details] [diff] [review]
Patch
Review of attachment 810099 [details] [diff] [review]:
-----------------------------------------------------------------
thanks for doing this. I like this test much better now. :)
r+ with the below changes.
::: browser/devtools/framework/test/browser_toolbox_options.js
@@ +15,5 @@
> + .then(testSelectTool)
> + .then(testOptionsShortcut)
> + .then(testOptions)
> + .then(testToggleTools)
> + .then(cleanup);
you should probably add a .then(null, errorHandler) to the end of this chain to capture any badness that might occur.
e.g., see, http://mxr.mozilla.org/mozilla-central/source/browser/devtools/debugger/test/browser_dbg_listtabs-01.js#32
@@ +113,5 @@
> + p = p.then(toggleTool.bind(null, node));
> + }
> + for (let node of enabledTools) {
> + p = p.then(toggleTool.bind(null, node));
> + }
so good we needed it twice?
I guess we're toggling so the first pass disables(?) then second enables?
still a little weird. Maybe update the comment to explain what's happening a little more clearly so people don't think it's a paste error.
@@ +126,5 @@
> + .then(toggleTool.bind(null, firstTool))
> + .then(toggleTool.bind(null, middleTool))
> + .then(toggleTool.bind(null, middleTool))
> + .then(toggleTool.bind(null, lastTool))
> + .then(toggleTool.bind(null, lastTool));
again, add another .then(null, errorHandler) in case Something Bad Happened™.
Attachment #810099 -
Flags: review?(rcampbell) → review+
Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Rob Campbell [:rc] (:robcee) from comment #8)
> @@ +126,5 @@
> > + .then(toggleTool.bind(null, firstTool))
> > + .then(toggleTool.bind(null, middleTool))
> > + .then(toggleTool.bind(null, middleTool))
> > + .then(toggleTool.bind(null, lastTool))
> > + .then(toggleTool.bind(null, lastTool));
>
> again, add another .then(null, errorHandler) in case Something Bad Happened™.
testToggleTools adds all these .then()s into the main promise chain from onLoad, so just adding the errorHandler to the end of the onLoad chain is enough to catch errors thrown by toggleTool.
Assignee | ||
Comment 10•11 years ago
|
||
Adds requested comments and error handler. I also reset all modified preferences in the cleanup function, since this test can cause a lot of failures in following tests if it leaves a toolbox tab enabled/disabled when it shouldn't be.
Attachment #810099 -
Attachment is obsolete: true
Assignee | ||
Comment 11•11 years ago
|
||
Rebased onto fx-team.
Attachment #814223 -
Attachment is obsolete: true
Assignee | ||
Updated•11 years ago
|
Whiteboard: [checkin-needed]
Comment 12•11 years ago
|
||
Assignee: nobody → rjacob
Flags: in-testsuite+
Whiteboard: [checkin-needed] → [fixed-in-fx-team]
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 27
Comment 14•11 years ago
|
||
Thanks Jake!
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•