Bug 1432865 - Clean up show and hideColumn test API. r=Honza

MozReview-Commit-ID: EGL5wC3UPa2

--HG--
extra : rebase_source : 15f871aa04e3afab719ab9687d51b68b16b9f66a
This commit is contained in:
abhinav 2018-01-25 16:45:34 +05:30
Родитель 0732ef3648
Коммит 5bb7f4be73
5 изменённых файлов: 35 добавлений и 38 удалений

Просмотреть файл

@ -7,8 +7,8 @@
* Tests that last visible column can't be hidden * Tests that last visible column can't be hidden
*/ */
add_task(function* () { add_task(async function () {
let { monitor } = yield initNetMonitor(SIMPLE_URL); let { monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... "); info("Starting test... ");
let { document, store, parent } = monitor.panelWin; let { document, store, parent } = monitor.panelWin;
@ -29,32 +29,18 @@ add_task(function* () {
if (!shown) { if (!shown) {
continue; continue;
} }
yield testLastMenuItem(column); await testLastMenuItem(column);
break; break;
} }
if (shown) { if (shown) {
yield hideColumn(column); await hideColumn(monitor, column);
} }
} }
yield teardown(monitor); await teardown(monitor);
function* hideColumn(column) { async function testLastMenuItem(column) {
info(`Clicking context-menu item for ${column}`);
EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector("#requests-list-status-button") ||
document.querySelector("#requests-list-waterfall-button"));
let onHeaderRemoved = waitForDOM(document, `#requests-list-${column}-button`, 0);
parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
yield onHeaderRemoved;
ok(!document.querySelector(`#requests-list-${column}-button`),
`Column ${column} should be hidden`);
}
function* testLastMenuItem(column) {
EventUtils.sendMouseEvent({ type: "contextmenu" }, EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector(`#requests-list-${column}-button`)); document.querySelector(`#requests-list-${column}-button`));

Просмотреть файл

@ -7,11 +7,11 @@
* Tests if visible columns are properly saved * Tests if visible columns are properly saved
*/ */
add_task(function* () { add_task(async function () {
Services.prefs.setCharPref("devtools.netmonitor.visibleColumns", Services.prefs.setCharPref("devtools.netmonitor.visibleColumns",
'["status", "contentSize", "waterfall"]'); '["status", "contentSize", "waterfall"]');
let { monitor } = yield initNetMonitor(SIMPLE_URL); let { monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... "); info("Starting test... ");
let { document } = monitor.panelWin; let { document } = monitor.panelWin;
@ -21,8 +21,8 @@ add_task(function* () {
ok(document.querySelector("#requests-list-contentSize-button"), ok(document.querySelector("#requests-list-contentSize-button"),
"Content size column should be shown"); "Content size column should be shown");
yield hideColumn(monitor, "status"); await hideColumn(monitor, "status");
yield hideColumn(monitor, "contentSize"); await hideColumn(monitor, "contentSize");
let visibleColumns = JSON.parse( let visibleColumns = JSON.parse(
Services.prefs.getCharPref("devtools.netmonitor.visibleColumns") Services.prefs.getCharPref("devtools.netmonitor.visibleColumns")
@ -33,7 +33,7 @@ add_task(function* () {
ok(!visibleColumns.includes("contentSize"), ok(!visibleColumns.includes("contentSize"),
"Pref should be synced for contentSize"); "Pref should be synced for contentSize");
yield showColumn(monitor, "status"); await showColumn(monitor, "status");
visibleColumns = JSON.parse( visibleColumns = JSON.parse(
Services.prefs.getCharPref("devtools.netmonitor.visibleColumns") Services.prefs.getCharPref("devtools.netmonitor.visibleColumns")

Просмотреть файл

@ -6,8 +6,8 @@
/** /**
* Tests reset column menu item * Tests reset column menu item
*/ */
add_task(function* () { add_task(async function () {
let { monitor } = yield initNetMonitor(SIMPLE_URL); let { monitor } = await initNetMonitor(SIMPLE_URL);
info("Starting test... "); info("Starting test... ");
let { document, parent, windowRequire } = monitor.panelWin; let { document, parent, windowRequire } = monitor.panelWin;
@ -15,8 +15,8 @@ add_task(function* () {
let prefBefore = Prefs.visibleColumns; let prefBefore = Prefs.visibleColumns;
hideColumn(monitor, "status"); await hideColumn(monitor, "status");
hideColumn(monitor, "waterfall"); await hideColumn(monitor, "waterfall");
EventUtils.sendMouseEvent({ type: "contextmenu" }, EventUtils.sendMouseEvent({ type: "contextmenu" },
document.querySelector("#requests-list-contentSize-button")); document.querySelector("#requests-list-contentSize-button"));

Просмотреть файл

@ -14,11 +14,22 @@ add_task(async function () {
let Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); let Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false)); store.dispatch(Actions.batchEnable(false));
hideColumn(monitor, "waterfall"); let visibleColumns = store.getState().ui.columns;
showColumn(monitor, "endTime");
showColumn(monitor, "responseTime"); // Hide the waterfall column to make sure timing data are fetched
showColumn(monitor, "duration"); // by the other timing columns ("endTime", "responseTime", "duration",
showColumn(monitor, "latency"); // "latency").
// Note that all these timing columns are based on the same
// `RequestListColumnTime` component.
if (visibleColumns.waterfall) {
await hideColumn(monitor, "waterfall");
}
["endTime", "responseTime", "duration", "latency"].forEach(async (column) => {
if (!visibleColumns[column]) {
await showColumn(monitor, column);
}
});
let onNetworkEvents = waitForNetworkEvents(monitor, 1); let onNetworkEvents = waitForNetworkEvents(monitor, 1);
let onEventTimings = waitFor(monitor.panelWin, EVENTS.RECEIVED_EVENT_TIMINGS); let onEventTimings = waitFor(monitor.panelWin, EVENTS.RECEIVED_EVENT_TIMINGS);

Просмотреть файл

@ -706,7 +706,7 @@ function testColumnsAlignment(headers, requestList) {
} }
} }
function* hideColumn(monitor, column) { async function hideColumn(monitor, column) {
let { document, parent } = monitor.panelWin; let { document, parent } = monitor.panelWin;
info(`Clicking context-menu item for ${column}`); info(`Clicking context-menu item for ${column}`);
@ -715,13 +715,13 @@ function* hideColumn(monitor, column) {
let onHeaderRemoved = waitForDOM(document, `#requests-list-${column}-button`, 0); let onHeaderRemoved = waitForDOM(document, `#requests-list-${column}-button`, 0);
parent.document.querySelector(`#request-list-header-${column}-toggle`).click(); parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
yield onHeaderRemoved; await onHeaderRemoved;
ok(!document.querySelector(`#requests-list-${column}-button`), ok(!document.querySelector(`#requests-list-${column}-button`),
`Column ${column} should be hidden`); `Column ${column} should be hidden`);
} }
function* showColumn(monitor, column) { async function showColumn(monitor, column) {
let { document, parent } = monitor.panelWin; let { document, parent } = monitor.panelWin;
info(`Clicking context-menu item for ${column}`); info(`Clicking context-menu item for ${column}`);
@ -730,7 +730,7 @@ function* showColumn(monitor, column) {
let onHeaderAdded = waitForDOM(document, `#requests-list-${column}-button`, 1); let onHeaderAdded = waitForDOM(document, `#requests-list-${column}-button`, 1);
parent.document.querySelector(`#request-list-header-${column}-toggle`).click(); parent.document.querySelector(`#request-list-header-${column}-toggle`).click();
yield onHeaderAdded; await onHeaderAdded;
ok(document.querySelector(`#requests-list-${column}-button`), ok(document.querySelector(`#requests-list-${column}-button`),
`Column ${column} should be visible`); `Column ${column} should be visible`);