зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1113552 - Use add_task in all browser/devtools/timeline browser mochitests; r=paul
This commit is contained in:
Родитель
3c0bacbcdc
Коммит
c97d8a36c9
|
@ -6,7 +6,7 @@
|
|||
* You can also use this initialization format as a template for other tests.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
|
||||
ok(target, "Should have a target available.");
|
||||
|
@ -15,7 +15,4 @@ let test = Task.async(function*() {
|
|||
ok(panel.panelWin.gToolbox, "Should have a toolbox reference on the panel window.");
|
||||
ok(panel.panelWin.gTarget, "Should have a target reference on the panel window.");
|
||||
ok(panel.panelWin.gFront, "Should have a front reference on the panel window.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Tests if the timeline blueprint has a correct structure.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
add_task(function*() {
|
||||
let { TIMELINE_BLUEPRINT } = devtools.require("devtools/timeline/global");
|
||||
|
||||
ok(TIMELINE_BLUEPRINT,
|
||||
|
@ -24,6 +24,4 @@ function test() {
|
|||
ok("label" in value,
|
||||
"Each entry in the timeline blueprint contains a `label` key.");
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* and there is data available.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, EVENTS, TimelineView, TimelineController } = panel.panelWin;
|
||||
let { OVERVIEW_INITIAL_SELECTION_RATIO: selectionRatio } = panel.panelWin;
|
||||
|
@ -41,7 +41,4 @@ let test = Task.async(function*() {
|
|||
is((selection.end - selection.start) | 0,
|
||||
(selectionRatio * TimelineView.markersOverview.width) | 0,
|
||||
"The initial selection end is correct.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* and there is no data available.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, EVENTS, TimelineView, TimelineController } = panel.panelWin;
|
||||
let { OVERVIEW_INITIAL_SELECTION_RATIO: selectionRatio } = panel.panelWin;
|
||||
|
@ -32,7 +32,4 @@ let test = Task.async(function*() {
|
|||
"The initial selection start is correct.");
|
||||
is(selection.end, null,
|
||||
"The initial selection end is correct.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Tests if the markers and memory overviews are continuously updated.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel("about:blank");
|
||||
let { $, EVENTS, TimelineView, TimelineController } = panel.panelWin;
|
||||
|
||||
|
@ -68,7 +68,4 @@ let test = Task.async(function*() {
|
|||
"The selection should now be enabled for the memory overview.");
|
||||
is(TimelineView.memoryOverview.hasSelection(), false,
|
||||
"The memory overview should not have a selection after recording.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* recording starts and stops.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, EVENTS } = panel.panelWin;
|
||||
|
||||
|
@ -36,7 +36,4 @@ let test = Task.async(function*() {
|
|||
"The record button should be unchecked again.");
|
||||
is($("#timeline-pane").selectedPanel, $("#timeline-waterfall-container"),
|
||||
"A waterfall view is now displayed.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Tests if the timeline actor isn't unnecessarily asked to record memory.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, EVENTS, TimelineView, TimelineController } = panel.panelWin;
|
||||
|
||||
|
@ -30,7 +30,4 @@ let test = Task.async(function*() {
|
|||
"There are some markers available.");
|
||||
is(memory.length, 0,
|
||||
"There are no memory measurements available.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Tests if the timeline can properly start and stop a recording.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, gFront, TimelineController } = panel.panelWin;
|
||||
|
||||
|
@ -34,7 +34,4 @@ let test = Task.async(function*() {
|
|||
ok(TimelineController.getInterval().endTime >
|
||||
TimelineController.getInterval().startTime,
|
||||
"Some time has passed since the recording started.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* the container bounds.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, EVENTS, TimelineView, TimelineController } = panel.panelWin;
|
||||
|
||||
|
@ -41,7 +41,4 @@ let test = Task.async(function*() {
|
|||
"The canvas width is correct.");
|
||||
is(TimelineView.waterfall._canvas.height, 1,
|
||||
"The canvas height is correct.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Tests if the waterfall is properly built after finishing a recording.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, $$, EVENTS, TimelineController } = panel.panelWin;
|
||||
|
||||
|
@ -62,7 +62,4 @@ let test = Task.async(function*() {
|
|||
"Some marker waterfall nodes should have been created.");
|
||||
ok($$(".waterfall-marker-item:not(spacer) > .waterfall-marker-bar").length,
|
||||
"Some marker color bars should have been created inside the waterfall.");
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Tests if the sidebar is properly updated when a marker is selected.
|
||||
*/
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { $, $$, EVENTS, TimelineController, TimelineView } = panel.panelWin;
|
||||
let { L10N } = devtools.require("devtools/timeline/global");
|
||||
|
@ -53,7 +53,4 @@ let test = Task.async(function*() {
|
|||
is(toMs(m.end), printedEndTime, "sidebar end time is valid");
|
||||
is(toMs(m.end - m.start), printedDuration, "sidebar duration is valid");
|
||||
}
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ var gRGB_TO_HSL = {
|
|||
"rgb(153, 153, 153)": "hsl(0,0%,60%)",
|
||||
};
|
||||
|
||||
let test = Task.async(function*() {
|
||||
add_task(function*() {
|
||||
let { target, panel } = yield initTimelinePanel(SIMPLE_URL);
|
||||
let { TIMELINE_BLUEPRINT } = devtools.require("devtools/timeline/global");
|
||||
let { $, $$, EVENTS, TimelineController } = panel.panelWin;
|
||||
|
@ -85,7 +85,4 @@ let test = Task.async(function*() {
|
|||
ok(bar.style.transform.match(/^translateX\(.*px\)$/),
|
||||
"The bar appears to have proper translations.");
|
||||
}
|
||||
|
||||
yield teardown(panel);
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -36,6 +36,16 @@ registerCleanupFunction(() => {
|
|||
Services.prefs.setBoolPref("devtools.timeline.enabled", gToolEnabled);
|
||||
});
|
||||
|
||||
// Close the toolbox and all opened tabs automatically.
|
||||
registerCleanupFunction(function*() {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
yield gDevTools.closeToolbox(target);
|
||||
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
});
|
||||
|
||||
function addTab(url) {
|
||||
info("Adding tab: " + url);
|
||||
|
||||
|
@ -52,22 +62,6 @@ function addTab(url) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
function removeTab(tab) {
|
||||
info("Removing tab.");
|
||||
|
||||
let deferred = promise.defer();
|
||||
let tabContainer = gBrowser.tabContainer;
|
||||
|
||||
tabContainer.addEventListener("TabClose", function onClose(aEvent) {
|
||||
tabContainer.removeEventListener("TabClose", onClose, false);
|
||||
info("Tab removed and finished closing.");
|
||||
deferred.resolve();
|
||||
}, false);
|
||||
|
||||
gBrowser.removeTab(tab);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns a new tab and starts up a toolbox with the timeline panel
|
||||
* automatically selected.
|
||||
|
@ -93,25 +87,6 @@ function* initTimelinePanel(url) {
|
|||
return { target, panel };
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a tab and destroys the toolbox holding a timeline panel.
|
||||
*
|
||||
* Must be used within a task.
|
||||
*
|
||||
* @param object panel
|
||||
* The timeline panel, created by the toolbox.
|
||||
* @return object
|
||||
* A promise resolved once the timeline, toolbox and debuggee tab
|
||||
* are destroyed.
|
||||
*/
|
||||
function* teardown(panel) {
|
||||
info("Destroying the specified timeline.");
|
||||
|
||||
let tab = panel.target.tab;
|
||||
yield panel._toolbox.destroy();
|
||||
yield removeTab(tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits until a predicate returns true.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче