зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1303484 - browser_device_modal_submit.js | unexpected number of devices; r=jryans
- Added `addDeviceForTest` that removes automatically the device added at the end of the test. - Improved `switchDevice` with more assertions. MozReview-Commit-ID: D1BJozD65uj
This commit is contained in:
Родитель
73ccc79fc3
Коммит
c7f9e0f637
|
@ -13,8 +13,6 @@ const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"]
|
|||
|
||||
const Types = require("devtools/client/responsive.html/types");
|
||||
|
||||
const { addDevice, removeDevice } = require("devtools/client/shared/devices");
|
||||
|
||||
const testDevice = {
|
||||
"name": "Fake Phone RDM Test",
|
||||
"width": 320,
|
||||
|
@ -28,7 +26,7 @@ const testDevice = {
|
|||
};
|
||||
|
||||
// Add the new device to the list
|
||||
addDevice(testDevice);
|
||||
addDeviceForTest(testDevice);
|
||||
|
||||
addRDMTask(TEST_URL, function* ({ ui, manager }) {
|
||||
let { store } = ui.toolWindow;
|
||||
|
@ -65,9 +63,6 @@ addRDMTask(TEST_URL, function* ({ ui, manager }) {
|
|||
yield testUserAgent(ui, DEFAULT_UA);
|
||||
yield testDevicePixelRatio(ui, 1);
|
||||
yield testTouchEventsOverride(ui, false);
|
||||
|
||||
ok(removeDevice(testDevice),
|
||||
"Test Device properly removed.");
|
||||
});
|
||||
|
||||
function testViewportDimensions(ui, w, h) {
|
||||
|
|
|
@ -4,7 +4,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
|
|||
"use strict";
|
||||
|
||||
// Test submitting display device changes on the device modal
|
||||
const { getDevices, addDevice } = require("devtools/client/shared/devices");
|
||||
const { getDevices } = require("devtools/client/shared/devices");
|
||||
|
||||
const addedDevice = {
|
||||
"name": "Fake Phone RDM Test",
|
||||
|
@ -107,7 +107,7 @@ addRDMTask(TEST_URL, function* ({ ui }) {
|
|||
checkedVal + " is unchecked in the device modal.");
|
||||
|
||||
// Let's add a dummy device to simulate featured flag changes for next test
|
||||
addDevice(addedDevice);
|
||||
addDeviceForTest(addedDevice);
|
||||
});
|
||||
|
||||
addRDMTask(TEST_URL, function* ({ ui }) {
|
||||
|
|
|
@ -37,6 +37,7 @@ const OPEN_DEVICE_MODAL_VALUE = "OPEN_DEVICE_MODAL";
|
|||
const { _loadPreferredDevices } = require("devtools/client/responsive.html/actions/devices");
|
||||
const { getOwnerWindow } = require("sdk/tabs/utils");
|
||||
const asyncStorage = require("devtools/shared/async-storage");
|
||||
const { addDevice, removeDevice } = require("devtools/client/shared/devices");
|
||||
|
||||
SimpleTest.requestCompleteLog();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -229,9 +230,14 @@ function openDeviceModal(ui) {
|
|||
"The device modal is displayed.");
|
||||
}
|
||||
|
||||
function switchDevice({ toolWindow }, name) {
|
||||
function switchDevice({ toolWindow }, value) {
|
||||
return new Promise(resolve => {
|
||||
let select = toolWindow.document.querySelector(".viewport-device-selector");
|
||||
let selector = ".viewport-device-selector";
|
||||
let select = toolWindow.document.querySelector(selector);
|
||||
isnot(select, null, `selector "${selector}" should match an existing element.`);
|
||||
|
||||
let option = [...select.options].find(o => o.value === String(value));
|
||||
isnot(option, undefined, `value "${value}" should match an existing option.`);
|
||||
|
||||
let event = new toolWindow.UIEvent("change", {
|
||||
view: toolWindow,
|
||||
|
@ -239,13 +245,13 @@ function switchDevice({ toolWindow }, name) {
|
|||
cancelable: true
|
||||
});
|
||||
|
||||
select.addEventListener("change", function onChange() {
|
||||
is(select.value, name, "Device should be selected");
|
||||
select.removeEventListener("change", onChange);
|
||||
select.addEventListener("change", () => {
|
||||
is(select.value, value,
|
||||
`Select's option with value "${value}" should be selected.`);
|
||||
resolve();
|
||||
});
|
||||
}, { once: true });
|
||||
|
||||
select.value = name;
|
||||
select.value = value;
|
||||
select.dispatchEvent(event);
|
||||
});
|
||||
}
|
||||
|
@ -312,3 +318,13 @@ function forward(browser) {
|
|||
browser.goForward();
|
||||
return shown;
|
||||
}
|
||||
|
||||
function addDeviceForTest(device) {
|
||||
info(`Adding Test Device "${device.name}" to the list.`);
|
||||
addDevice(device);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
// Note that assertions in cleanup functions are not displayed unless they failed.
|
||||
ok(removeDevice(device), `Removed Test Device "${device.name}" from the list.`);
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче