Closed Bug 875902 Opened 11 years ago Closed 11 years ago

[toolbox] Simplify selectTool and test for panel readiness

Categories

(DevTools :: Framework, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 24

People

(Reporter: dcrewi, Assigned: dcrewi)

Details

(Whiteboard: [fixed-in-fx-team])

Attachments

(1 file, 4 obsolete files)

When waiting for panels to load, the toolbox listens for the DOMContentLoaded event, but it should listen for the load event instead. This results in, at the very least, the promise returned by gDevTools.showToolbox(...) resolving before the panel is completely initialized, though only for some tools. This has caused me some problems when writing tests for other bugs.

The difference between the two events is defined here: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html
Assignee: nobody → dcrewi
Attached patch patch v1 (obsolete) — Splinter Review
Attachment #753918 - Flags: review?(dcamp)
I think I remember Paul mentioned that he used DOMContentLoaded on purpose, instead of the load event. I can't seem to recall the exact reason though...
Comment on attachment 753918 [details] [diff] [review]
patch v1

I think Joe is a better reviewer here.
Attachment #753918 - Flags: review?(dcamp) → review?(jwalker)
Comment on attachment 753918 [details] [diff] [review]
patch v1

Review of attachment 753918 [details] [diff] [review]:
-----------------------------------------------------------------

Hmmm.
I've not heard Paul say we should be using DOMContentLoaded, and it seems to me as though 'load' makes more sense here. But Paul is back in a few days time, so I suggest we wait and ask him.

Personally, I think I'd rather have a panel.ready() function that returns a promise that's resolved when the panel is ready. That means we don't need to expose the panelWin object everywhere. Does that make sense?
Attachment #753918 - Flags: review?(jwalker)
Attached patch patch v2, rebased (obsolete) — Splinter Review
Rebased.
Attachment #753918 - Attachment is obsolete: true
Well the other reason to expose panelWin is so that the test has something to test. I suppose that could be moved to an "isReady" property or method.
Attached patch patch v3, rewrite (obsolete) — Splinter Review
So what is the call on DOMContentLoaded vs load? Either way, this is a slightly better way to write selectTool and loadTool.
Attachment #756004 - Attachment is obsolete: true
Attachment #758137 - Flags: feedback?(paul)
(In reply to David Creswick from comment #0)
> When waiting for panels to load, the toolbox listens for the
> DOMContentLoaded event, but it should listen for the load event instead.
> This results in, at the very least, the promise returned by
> gDevTools.showToolbox(...) resolving before the panel is completely
> initialized, though only for some tools.

iirc, we use DOMContentLoaded for performance reasons (showing the tools as soon as possible).

> This has caused me some problems when writing tests for other bugs.

What kind of problems?
(In reply to Paul Rouget [:paul] from comment #8)
> (In reply to David Creswick from comment #0)
> 
> iirc, we use DOMContentLoaded for performance reasons (showing the tools as
> soon as possible).

Oh, I suppose that makes sense. I wasn't thinking about the interactive case.

> > This has caused me some problems when writing tests for other bugs.
> 
> What kind of problems?

In my test, I wanted access to the CssRuleView object of the inspector tool, but it isn't available until the window of the tab's iframe has loaded. I reviewed that case again this morning and realized I should probably be waiting for the rule view tab to load instead of the inspector panel. 
 
It wasn't unreasonable to imagine that tools would defer some initialization until the load event fires, so I wrote the test hoping to fix all cases. The options panel, the inspector panel, and the styleeditor panel all report to be ready before their content document's load event fires. It doesn't look like that is actually the problem I thought it was though.
Summary: [toolbox] Ensure a panel's document is completely loaded before resolving promise → [toolbox] Simplify selectTool and test for panel readiness
Hijacking this bug number to simplify selectTool and test for panel readiness.
Attachment #758137 - Attachment is obsolete: true
Attachment #758137 - Flags: feedback?(paul)
Attachment #760431 - Flags: review?(paul)
Attachment #760431 - Flags: review?(paul) → review+
Whiteboard: [land-in-fx-team]
Attached patch v5, bitrot fixedSplinter Review
Attachment #760431 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/1d0d9f1d6321
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 24
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: