Bug 1420179 - support tab argument in devtools shared-head refreshTab;r=nchevobbe
The tab argument was unused in the method. All the call sites have been updated to
stop providing this argument. The method now supports an optional tab argument.
It defaults to the selected tab if no argument is provided.
MozReview-Commit-ID: 621dgljHdtD
--- a/devtools/client/framework/test/browser_source_map-reload.js
+++ b/devtools/client/framework/test/browser_source_map-reload.js
@@ -31,17 +31,17 @@ add_task(function* () {
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
let newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL_1, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
// Reload the page. The sjs ensures that a different source file
// will be loaded.
sourceSeen = waitForSourceLoad(toolbox, JS_URL);
- yield refreshTab(tab);
+ yield refreshTab();
yield sourceSeen;
info(`checking post-reload original location for ${JS_URL}:${GENERATED_LINE}`);
newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL_2, "check post-reload mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check post-reload mapped line number");
yield toolbox.destroy();
--- a/devtools/client/framework/test/shared-head.js
+++ b/devtools/client/framework/test/shared-head.js
@@ -167,27 +167,27 @@ var removeTab = Task.async(function* (ta
let onClose = once(gBrowser.tabContainer, "TabClose");
gBrowser.removeTab(tab);
yield onClose;
info("Tab removed and finished closing");
});
/**
- * Refresh the given tab.
- * @param {Object} tab The tab to be refreshed.
+ * Refresh the provided tab.
+ * @param {Object} tab The tab to be refreshed. Defaults to the currently selected tab.
* @return Promise<undefined> resolved when the tab is successfully refreshed.
*/
-var refreshTab = Task.async(function*(tab) {
+var refreshTab = async function (tab = gBrowser.selectedTab) {
info("Refreshing tab.");
const finished = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
- gBrowser.reloadTab(gBrowser.selectedTab);
- yield finished;
+ gBrowser.reloadTab(tab);
+ await finished;
info("Tab finished refreshing.");
-});
+};
/**
* Simulate a key event from a <key> element.
* @param {DOMNode} key
*/
function synthesizeKeyFromKeyTag(key) {
is(key && key.tagName, "key", "Successfully retrieved the <key> node");
--- a/devtools/client/inspector/grids/test/browser_grids_restored-after-reload.js
+++ b/devtools/client/inspector/grids/test/browser_grids_restored-after-reload.js
@@ -57,17 +57,17 @@ add_task(function* () {
ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
info("Reload the page, expect the highlighter to be displayed once again and " +
"grid is checked");
let onStateRestored = highlighters.once("grid-state-restored");
let onGridListRestored = waitUntilState(store, state =>
state.grids.length == 1 &&
state.grids[0].highlighted);
- yield refreshTab(gBrowser.selectedTab);
+ yield refreshTab();
let { restored } = yield onStateRestored;
yield onGridListRestored;
info("Check that the grid highlighter can be displayed after reloading the page");
ok(restored, "The highlighter state was restored");
ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
info("Navigate to another URL, and check that the highlighter is hidden and " +
--- a/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-on-reload.js
+++ b/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-on-reload.js
@@ -20,17 +20,17 @@ add_task(function* () {
info("Check that the flexbox highlighter can be displayed.");
yield checkFlexboxHighlighter();
info("Close the toolbox before reloading the tab.");
let target = TargetFactory.forTab(gBrowser.selectedTab);
yield gDevTools.closeToolbox(target);
- yield refreshTab(gBrowser.selectedTab);
+ yield refreshTab();
info("Check that the flexbox highlighter can be displayed after reloading the page.");
yield checkFlexboxHighlighter();
});
function* checkFlexboxHighlighter() {
let {inspector, view} = yield openRuleView();
let {highlighters} = view;
--- a/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-restored-after-reload.js
+++ b/devtools/client/inspector/rules/test/browser_rules_flexbox-highlighter-restored-after-reload.js
@@ -39,17 +39,17 @@ add_task(function* () {
let onHighlighterShown = highlighters.once("flexbox-highlighter-shown");
flexboxToggle.click();
yield onHighlighterShown;
ok(highlighters.flexboxHighlighterShown, "Flexbox highlighter is shown.");
info("Reload the page, expect the highlighter to be displayed once again");
let onStateRestored = highlighters.once("flexbox-state-restored");
- yield refreshTab(gBrowser.selectedTab);
+ yield refreshTab();
let { restored } = yield onStateRestored;
ok(restored, "The highlighter state was restored");
info("Check that the flexbox highlighter can be displayed after reloading the page");
ok(highlighters.flexboxHighlighterShown, "Flexbox highlighter is shown.");
info("Navigate to another URL, and check that the highlighter is hidden");
let otherUri = "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI);
--- a/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-on-reload.js
+++ b/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-on-reload.js
@@ -25,17 +25,17 @@ add_task(function* () {
info("Check that the grid highlighter can be displayed");
yield checkGridHighlighter();
info("Close the toolbox before reloading the tab");
let target = TargetFactory.forTab(gBrowser.selectedTab);
yield gDevTools.closeToolbox(target);
- yield refreshTab(gBrowser.selectedTab);
+ yield refreshTab();
info("Check that the grid highlighter can be displayed after reloading the page");
yield checkGridHighlighter();
});
function* checkGridHighlighter() {
let {inspector, view} = yield openRuleView();
let {highlighters} = view;
--- a/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-restored-after-reload.js
+++ b/devtools/client/inspector/rules/test/browser_rules_grid-highlighter-restored-after-reload.js
@@ -46,17 +46,17 @@ add_task(function* () {
let onHighlighterShown = highlighters.once("grid-highlighter-shown");
gridToggle.click();
yield onHighlighterShown;
ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
info("Reload the page, expect the highlighter to be displayed once again");
let onStateRestored = highlighters.once("grid-state-restored");
- yield refreshTab(gBrowser.selectedTab);
+ yield refreshTab();
let { restored } = yield onStateRestored;
ok(restored, "The highlighter state was restored");
info("Check that the grid highlighter can be displayed after reloading the page");
ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
info("Navigate to another URL, and check that the highlighter is hidden");
let otherUri = "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI);
--- a/devtools/client/memory/test/browser/browser_memory_refresh_does_not_leak.js
+++ b/devtools/client/memory/test/browser/browser_memory_refresh_does_not_leak.js
@@ -53,17 +53,17 @@ const DESCRIPTION = {
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const front = panel.panelWin.gFront;
const startWindows = yield getWindowsInSnapshot(front);
dumpn("Initial windows found = " + startWindows.map(w => "0x" +
w.toString(16)).join(", "));
is(startWindows.length, 1);
- yield refreshTab(tab);
+ yield refreshTab();
const endWindows = yield getWindowsInSnapshot(front);
is(endWindows.length, 1);
if (endWindows.length === 1) {
return;
}