Bug 1648616 - Remove all references to "usingBrowsingUI" option in RDM tests. r=gl

Depends on D82427

Differential Revision: https://phabricator.services.mozilla.com/D82428
This commit is contained in:
Micah Tigley 2020-07-09 20:20:17 +00:00
Родитель bc9e0dd52e
Коммит 47a80c7dfa
65 изменённых файлов: 1053 добавлений и 1225 удалений

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

@ -29,5 +29,5 @@ addRDMTask(
ok(newTab, "New tab opened from link");
await removeTab(newTab);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -26,5 +26,5 @@ addRDMTask(
await closeRDM(tab);
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -4,62 +4,52 @@
const TEST_URI = `${URL_ROOT}doc_contextmenu_inspect.html`;
addRDMTask(
TEST_URI,
async function({ ui, manager }) {
info(
"Open the responsive design mode and set its size to 500x500 to start"
);
await setViewportSize(ui, manager, 500, 500);
addRDMTask(TEST_URI, async function({ ui, manager }) {
info("Open the responsive design mode and set its size to 500x500 to start");
await setViewportSize(ui, manager, 500, 500);
info("Open the inspector, rule-view and select the test node");
const { inspector } = await openRuleView();
info("Open the inspector, rule-view and select the test node");
const { inspector } = await openRuleView();
const startNodeFront = inspector.selection.nodeFront;
is(
startNodeFront.displayName,
"body",
"body element is selected by default"
);
const startNodeFront = inspector.selection.nodeFront;
is(startNodeFront.displayName, "body", "body element is selected by default");
const onSelected = inspector.once("inspector-updated");
const onSelected = inspector.once("inspector-updated");
const contentAreaContextMenu = document.querySelector(
"#contentAreaContextMenu"
);
const contextOpened = once(contentAreaContextMenu, "popupshown");
const contentAreaContextMenu = document.querySelector(
"#contentAreaContextMenu"
);
const contextOpened = once(contentAreaContextMenu, "popupshown");
info("Simulate a context menu event from the top browser.");
BrowserTestUtils.synthesizeMouse(
ui.getViewportBrowser(),
250,
100,
{
type: "contextmenu",
button: 2,
},
ui.tab.linkedBrowser
);
info("Simulate a context menu event from the top browser.");
BrowserTestUtils.synthesizeMouse(
ui.getViewportBrowser(),
250,
100,
{
type: "contextmenu",
button: 2,
},
ui.tab.linkedBrowser
);
await contextOpened;
await contextOpened;
info("Triggering the inspect action");
await gContextMenu.inspectNode();
info("Triggering the inspect action");
await gContextMenu.inspectNode();
info("Hiding the menu");
const contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidePopup();
await contextClosed;
info("Hiding the menu");
const contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidePopup();
await contextClosed;
await onSelected;
const newNodeFront = inspector.selection.nodeFront;
is(
newNodeFront.displayName,
"div",
"div element is selected after using Inspect Element"
);
await onSelected;
const newNodeFront = inspector.selection.nodeFront;
is(
newNodeFront.displayName,
"div",
"div element is selected after using Inspect Element"
);
await closeToolbox();
},
{ usingBrowserUI: true }
);
await closeToolbox();
});

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

@ -77,7 +77,7 @@ addRDMTask(
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -120,5 +120,5 @@ addRDMTask(
reloadOnUAChange(false);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -65,7 +65,7 @@ addRDMTask(
ok(menuItem, "Custom device menu item added to device selector");
});
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -126,7 +126,7 @@ addRDMTask(
info("Ensure device properties like UA have been reset");
await testUserAgent(ui, navigator.userAgent);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -163,7 +163,7 @@ addRDMTask(
ok(menuItem, "Custom unicode device option added to device selector");
});
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -182,7 +182,7 @@ addRDMTask(
ok(menuItem, "Custom unicode device option present in device selector");
});
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
function testDeviceAdder(ui, expected) {

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

@ -113,5 +113,5 @@ addRDMTask(
ok(editedDevice, "Edited Custom Device menu item exists");
});
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -97,7 +97,7 @@ addRDMTask(
ok(!deviceItem2, "Test device 2 menu item removed");
});
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -135,5 +135,5 @@ addRDMTask(
const deviceCb2 = deviceCbs.find(cb => cb.value == device2.name);
ok(!deviceCb2, "Test device 2 checkbox does not exist");
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -15,23 +15,19 @@ add_task(async function() {
});
});
addRDMTask(
TEST_URL,
async function({ ui }) {
const { store, document } = ui.toolWindow;
const button = document.getElementById("device-selector");
addRDMTask(TEST_URL, async function({ ui }) {
const { store, document } = ui.toolWindow;
const button = document.getElementById("device-selector");
// Wait until the viewport has been added and the device list state indicates
// an error
await waitUntilState(
store,
state =>
state.viewports.length == 1 &&
state.devices.listState == Types.loadableState.ERROR
);
// Wait until the viewport has been added and the device list state indicates
// an error
await waitUntilState(
store,
state =>
state.viewports.length == 1 &&
state.devices.listState == Types.loadableState.ERROR
);
// The device selector should be disabled
ok(button.disabled, "Device selector is disabled");
},
{ usingBrowserUI: true }
);
// The device selector should be disabled
ok(button.disabled, "Device selector is disabled");
});

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

@ -47,5 +47,5 @@ addRDMTask(
value + " was not added to removed device list."
);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -58,7 +58,7 @@ addRDMTask(
}
}
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
function findDeviceLabel(deviceName, document) {

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

@ -140,7 +140,7 @@ addRDMTask(
// Let's add a dummy device to simulate featured flag changes for next test
addDeviceForTest(addedDevice);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -188,5 +188,5 @@ addRDMTask(
}
});
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -35,7 +35,7 @@ addRDMTask(
await testResetWhenResizingViewport(ui);
await testChangingDevicePixelRatio(ui);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
async function waitStartup(ui) {

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

@ -67,5 +67,5 @@ addRDMTask(
is(backgroundImage, icon, "The icon is correct");
}
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -61,7 +61,7 @@ addRDMTask(
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -98,7 +98,7 @@ addRDMTask(
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -132,5 +132,5 @@ addRDMTask(
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -7,47 +7,43 @@ const TEST_URL =
'data:text/html;charset=utf-8,<iframe id="subframe" ' +
'width="200" height="200"></iframe>';
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
ok(ui, "An instance of the RDM should be attached to the tab.");
await setViewportSizeAndAwaitReflow(ui, manager, 110, 500);
addRDMTask(TEST_URL, async function({ ui, manager }) {
ok(ui, "An instance of the RDM should be attached to the tab.");
await setViewportSizeAndAwaitReflow(ui, manager, 110, 500);
info("Checking initial width/height properties.");
await doInitialChecks(ui, 110);
info("Checking initial width/height properties.");
await doInitialChecks(ui, 110);
info("Checking initial width/height with meta viewport on");
await setTouchAndMetaViewportSupport(ui, true);
await doInitialChecks(ui, 980);
await setTouchAndMetaViewportSupport(ui, false);
info("Checking initial width/height with meta viewport on");
await setTouchAndMetaViewportSupport(ui, true);
await doInitialChecks(ui, 980);
await setTouchAndMetaViewportSupport(ui, false);
info("Changing the RDM size");
await setViewportSizeAndAwaitReflow(ui, manager, 90, 500);
info("Changing the RDM size");
await setViewportSizeAndAwaitReflow(ui, manager, 90, 500);
info("Checking for screen props");
await checkScreenProps(ui);
info("Checking for screen props");
await checkScreenProps(ui);
info("Checking for screen props with meta viewport on");
await setTouchAndMetaViewportSupport(ui, true);
await checkScreenProps(ui);
await setTouchAndMetaViewportSupport(ui, false);
info("Checking for screen props with meta viewport on");
await setTouchAndMetaViewportSupport(ui, true);
await checkScreenProps(ui);
await setTouchAndMetaViewportSupport(ui, false);
info("Checking for subframe props");
await checkSubframeProps(ui);
info("Checking for subframe props");
await checkSubframeProps(ui);
info("Checking for subframe props with meta viewport on");
await setTouchAndMetaViewportSupport(ui, true);
await checkSubframeProps(ui);
await setTouchAndMetaViewportSupport(ui, false);
info("Checking for subframe props with meta viewport on");
await setTouchAndMetaViewportSupport(ui, true);
await checkSubframeProps(ui);
await setTouchAndMetaViewportSupport(ui, false);
info("Changing the RDM size using input keys");
await setViewportSizeWithInputKeys(ui);
info("Changing the RDM size using input keys");
await setViewportSizeWithInputKeys(ui);
info("Checking for screen props once again.");
await checkScreenProps2(ui);
},
{ usingBrowserUI: true }
);
info("Checking for screen props once again.");
await checkScreenProps2(ui);
});
async function setViewportSizeWithInputKeys(ui) {
const width = 320,

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

@ -45,7 +45,7 @@ addRDMTask(
await testExitButton(await openRDM(tab));
await BrowserTestUtils.closeWindow(newWindow);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);
async function waitBootstrap(ui) {

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

@ -89,8 +89,7 @@ addRDMTaskWithPreAndPost(
"ping-pong",
"Got the expected message back from the content script"
);
},
{ usingBrowserUI: true }
}
);
add_task(async function cleanup_first_test() {
@ -99,138 +98,134 @@ add_task(async function cleanup_first_test() {
await extension.unload();
});
addRDMTask(
TEST_URL,
async function test_tab_sender() {
const extension2 = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs"],
addRDMTask(TEST_URL, async function test_tab_sender() {
const extension2 = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs"],
content_scripts: [
{
matches: [TEST_URL],
js: ["content-script.js"],
run_at: "document_start",
},
],
},
content_scripts: [
{
matches: [TEST_URL],
js: ["content-script.js"],
run_at: "document_start",
},
],
},
async background() {
const TEST_URL = "http://example.com/"; // eslint-disable-line no-shadow
async background() {
const TEST_URL = "http://example.com/"; // eslint-disable-line no-shadow
browser.test.log("Background script init");
browser.test.log("Background script init");
let extTab;
const contentMessage = new Promise(resolve => {
browser.test.log("Listen to content");
const listener = async (msg, sender, respond) => {
browser.test.assertEq(
msg,
"hello-from-content",
"Background script got hello-from-content message"
);
let extTab;
const contentMessage = new Promise(resolve => {
browser.test.log("Listen to content");
const listener = async (msg, sender, respond) => {
browser.test.assertEq(
msg,
"hello-from-content",
"Background script got hello-from-content message"
);
const tabs = await browser.tabs.query({
currentWindow: true,
active: true,
});
browser.test.assertEq(
tabs.length,
1,
"One tab is active in the current window"
);
extTab = tabs[0];
browser.test.log(`Tab: id ${extTab.id}, url ${extTab.url}`);
browser.test.assertEq(extTab.url, TEST_URL, "Tab has the test URL");
const tabs = await browser.tabs.query({
currentWindow: true,
active: true,
});
browser.test.assertEq(
tabs.length,
1,
"One tab is active in the current window"
);
extTab = tabs[0];
browser.test.log(`Tab: id ${extTab.id}, url ${extTab.url}`);
browser.test.assertEq(extTab.url, TEST_URL, "Tab has the test URL");
browser.test.assertTrue(!!sender, "Message has a sender");
browser.test.assertTrue(!!sender.tab, "Message has a sender.tab");
browser.test.assertEq(
sender.tab.id,
extTab.id,
"Sender's tab ID matches the RDM tab ID"
);
browser.test.assertEq(
sender.tab.url,
extTab.url,
"Sender's tab URL matches the RDM tab URL"
);
browser.test.assertTrue(!!sender, "Message has a sender");
browser.test.assertTrue(!!sender.tab, "Message has a sender.tab");
browser.test.assertEq(
sender.tab.id,
extTab.id,
"Sender's tab ID matches the RDM tab ID"
);
browser.test.assertEq(
sender.tab.url,
extTab.url,
"Sender's tab URL matches the RDM tab URL"
);
browser.runtime.onMessage.removeListener(listener);
resolve();
};
browser.runtime.onMessage.addListener(listener);
browser.runtime.onMessage.removeListener(listener);
resolve();
};
browser.runtime.onMessage.addListener(listener);
});
// Wait for "resume" message so we know the content script is also ready.
await new Promise(resolve => {
browser.test.onMessage.addListener(resolve);
browser.test.sendMessage("background-script-ready");
});
await contentMessage;
browser.test.log("Send message from background to content");
const contentSender = await browser.tabs.sendMessage(
extTab.id,
"hello-from-background"
);
browser.test.assertEq(
contentSender.id,
browser.runtime.id,
"The sender ID in content matches this extension"
);
browser.test.notifyPass("rdm-messaging");
},
files: {
"content-script.js": async function() {
browser.test.log("Content script init");
browser.test.log("Listen to background");
browser.runtime.onMessage.addListener((msg, sender, respond) => {
browser.test.assertEq(
msg,
"hello-from-background",
"Content script got hello-from-background message"
);
browser.test.assertTrue(!!sender, "Message has a sender");
browser.test.assertTrue(!!sender.id, "Message has a sender.id");
const { id } = sender;
respond({ id });
});
// Wait for "resume" message so we know the content script is also ready.
// Wait for "resume" message so we know the background script is also ready.
await new Promise(resolve => {
browser.test.onMessage.addListener(resolve);
browser.test.sendMessage("background-script-ready");
browser.test.sendMessage("content-script-ready");
});
await contentMessage;
browser.test.log("Send message from background to content");
const contentSender = await browser.tabs.sendMessage(
extTab.id,
"hello-from-background"
);
browser.test.assertEq(
contentSender.id,
browser.runtime.id,
"The sender ID in content matches this extension"
);
browser.test.notifyPass("rdm-messaging");
browser.test.log("Send message from content to background");
browser.runtime.sendMessage("hello-from-content");
},
},
});
files: {
"content-script.js": async function() {
browser.test.log("Content script init");
const contentScriptReady = extension2.awaitMessage("content-script-ready");
const backgroundScriptReady = extension2.awaitMessage(
"background-script-ready"
);
const finish = extension2.awaitFinish("rdm-messaging");
browser.test.log("Listen to background");
browser.runtime.onMessage.addListener((msg, sender, respond) => {
browser.test.assertEq(
msg,
"hello-from-background",
"Content script got hello-from-background message"
);
await extension2.startup();
browser.test.assertTrue(!!sender, "Message has a sender");
browser.test.assertTrue(!!sender.id, "Message has a sender.id");
// It appears the background script and content script can loaded in either order, so
// we'll wait for the both to listen before proceeding.
await backgroundScriptReady;
await contentScriptReady;
extension2.sendMessage("resume");
const { id } = sender;
respond({ id });
});
// Wait for "resume" message so we know the background script is also ready.
await new Promise(resolve => {
browser.test.onMessage.addListener(resolve);
browser.test.sendMessage("content-script-ready");
});
browser.test.log("Send message from content to background");
browser.runtime.sendMessage("hello-from-content");
},
},
});
const contentScriptReady = extension2.awaitMessage("content-script-ready");
const backgroundScriptReady = extension2.awaitMessage(
"background-script-ready"
);
const finish = extension2.awaitFinish("rdm-messaging");
await extension2.startup();
// It appears the background script and content script can loaded in either order, so
// we'll wait for the both to listen before proceeding.
await backgroundScriptReady;
await contentScriptReady;
extension2.sendMessage("resume");
await finish;
await extension2.unload();
},
{ usingBrowserUI: true }
);
await finish;
await extension2.unload();
});

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

@ -8,28 +8,24 @@
const TEST_URL = "http://example.com/";
addRDMTask(
TEST_URL,
async function({ ui }) {
const viewportBrowser = ui.getViewportBrowser();
addRDMTask(TEST_URL, async function({ ui }) {
const viewportBrowser = ui.getViewportBrowser();
const contentURL = await SpecialPowers.spawn(
viewportBrowser,
[],
() => content.document.URL
);
info("content URL is " + contentURL);
const contentURL = await SpecialPowers.spawn(
viewportBrowser,
[],
() => content.document.URL
);
info("content URL is " + contentURL);
const contentInRDMPane = await SpecialPowers.spawn(
viewportBrowser,
[],
() => docShell.browsingContext.inRDMPane
);
const contentInRDMPane = await SpecialPowers.spawn(
viewportBrowser,
[],
() => docShell.browsingContext.inRDMPane
);
ok(
contentInRDMPane,
"After RDM is opened, document should have inRDMPane set to true."
);
},
{ usingBrowserUI: true }
);
ok(
contentInRDMPane,
"After RDM is opened, document should have inRDMPane set to true."
);
});

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

@ -7,34 +7,30 @@
const TEST_URL = "http://example.com/";
addRDMTask(
TEST_URL,
async function({ ui }) {
info("Toggling on touch simulation.");
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
addRDMTask(TEST_URL, async function({ ui }) {
info("Toggling on touch simulation.");
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
info(
"Test value maxTouchPoints is non-zero when touch simulation is enabled."
info(
"Test value maxTouchPoints is non-zero when touch simulation is enabled."
);
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
is(
content.navigator.maxTouchPoints,
1,
"navigator.maxTouchPoints should be 1"
);
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
is(
content.navigator.maxTouchPoints,
1,
"navigator.maxTouchPoints should be 1"
);
});
});
info("Toggling off touch simulation.");
await toggleTouchSimulation(ui);
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
is(
content.navigator.maxTouchPoints,
0,
"navigator.maxTouchPoints should be 0"
);
});
reloadOnTouchChange(false);
},
{ usingBrowserUI: true }
);
info("Toggling off touch simulation.");
await toggleTouchSimulation(ui);
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
is(
content.navigator.maxTouchPoints,
0,
"navigator.maxTouchPoints should be 0"
);
});
reloadOnTouchChange(false);
});

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

@ -57,8 +57,7 @@ addRDMTaskWithPreAndPost(
},
function post_task() {
ok(!isMenuChecked(), "RDM menu item is unchecked after RDM is closed");
},
{ usingBrowserUI: true }
}
);
add_task(async function() {

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

@ -55,5 +55,5 @@ addRDMTask(
ok(!isMenuCheckedFor(window), "RDM menu item is unchecked");
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -43,5 +43,5 @@ addRDMTask(
ui
);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -98,5 +98,5 @@ addRDMTask(
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -8,26 +8,22 @@ const throttlingProfiles = require("devtools/client/shared/components/throttling
// Tests changing network throttling
const TEST_URL = "data:text/html;charset=utf-8,Network throttling test";
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
// Test defaults
testNetworkThrottlingSelectorLabel(ui, "No Throttling");
await testNetworkThrottlingState(ui, null);
addRDMTask(TEST_URL, async function({ ui, manager }) {
// Test defaults
testNetworkThrottlingSelectorLabel(ui, "No Throttling");
await testNetworkThrottlingState(ui, null);
// Test a fast profile
await testThrottlingProfile(ui, "Wi-Fi");
// Test a fast profile
await testThrottlingProfile(ui, "Wi-Fi");
// Test a slower profile
await testThrottlingProfile(ui, "Regular 3G");
// Test a slower profile
await testThrottlingProfile(ui, "Regular 3G");
// Test switching back to no throttling
await selectNetworkThrottling(ui, "No Throttling");
testNetworkThrottlingSelectorLabel(ui, "No Throttling");
await testNetworkThrottlingState(ui, null);
},
{ usingBrowserUI: true }
);
// Test switching back to no throttling
await selectNetworkThrottling(ui, "No Throttling");
testNetworkThrottlingSelectorLabel(ui, "No Throttling");
await testNetworkThrottlingState(ui, null);
});
function testNetworkThrottlingSelectorLabel(ui, expected) {
const title = ui.toolWindow.document.querySelector(

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

@ -21,83 +21,77 @@ const testDevice = {
// Add the new device to the list
addDeviceForTest(testDevice);
addRDMTask(
TEST_URL,
async function({ ui }) {
info("Rotate viewport to trigger 'orientationchange' event.");
await pushPref("devtools.responsive.viewport.angle", 0);
rotateViewport(ui);
addRDMTask(TEST_URL, async function({ ui }) {
info("Rotate viewport to trigger 'orientationchange' event.");
await pushPref("devtools.responsive.viewport.angle", 0);
rotateViewport(ui);
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
info(
"Check the original orientation values before the orientationchange"
);
is(
content.screen.orientation.type,
"portrait-primary",
"Primary orientation type is portrait-primary."
);
is(
content.screen.orientation.angle,
0,
"Original angle is set at 0 degrees"
);
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
info("Check the original orientation values before the orientationchange");
is(
content.screen.orientation.type,
"portrait-primary",
"Primary orientation type is portrait-primary."
);
is(
content.screen.orientation.angle,
0,
"Original angle is set at 0 degrees"
);
const orientationChange = new Promise(resolve => {
content.window.addEventListener("orientationchange", () => {
ok(true, "'orientationchange' event fired");
is(
content.screen.orientation.type,
"landscape-primary",
"Orientation state was updated to landscape-primary"
);
is(
content.screen.orientation.angle,
90,
"Orientation angle was updated to 90 degrees."
);
resolve();
});
const orientationChange = new Promise(resolve => {
content.window.addEventListener("orientationchange", () => {
ok(true, "'orientationchange' event fired");
is(
content.screen.orientation.type,
"landscape-primary",
"Orientation state was updated to landscape-primary"
);
is(
content.screen.orientation.angle,
90,
"Orientation angle was updated to 90 degrees."
);
resolve();
});
await orientationChange;
});
info("Check that the viewport orientation values persist after reload");
const browser = ui.getViewportBrowser();
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
await orientationChange;
});
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
info("Check that we still have the previous orientation values.");
is(content.screen.orientation.angle, 90, "Orientation angle is still 90");
is(
content.screen.orientation.type,
"landscape-primary",
"Orientation is still landscape-primary."
);
});
info("Check that the viewport orientation values persist after reload");
const browser = ui.getViewportBrowser();
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
info(
"Check the orientationchange event is not dispatched when changing devices."
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
info("Check that we still have the previous orientation values.");
is(content.screen.orientation.angle, 90, "Orientation angle is still 90");
is(
content.screen.orientation.type,
"landscape-primary",
"Orientation is still landscape-primary."
);
const onViewportOrientationChange = once(
ui,
"only-viewport-orientation-changed"
);
await selectDevice(ui, "Fake Phone RDM Test");
await onViewportOrientationChange;
});
await ContentTask.spawn(ui.getViewportBrowser(), {}, async function() {
info("Check the new orientation values after selecting device.");
is(content.screen.orientation.angle, 0, "Orientation angle is 0");
is(
content.screen.orientation.type,
"portrait-primary",
"New orientation is portrait-primary."
);
});
},
{ usingBrowserUI: true }
);
info(
"Check the orientationchange event is not dispatched when changing devices."
);
const onViewportOrientationChange = once(
ui,
"only-viewport-orientation-changed"
);
await selectDevice(ui, "Fake Phone RDM Test");
await onViewportOrientationChange;
await ContentTask.spawn(ui.getViewportBrowser(), {}, async function() {
info("Check the new orientation values after selecting device.");
is(content.screen.orientation.angle, 0, "Orientation angle is 0");
is(
content.screen.orientation.type,
"portrait-primary",
"New orientation is portrait-primary."
);
});
});

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

@ -55,7 +55,7 @@ addRDMTask(
await closeRDM(tab);
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);
async function openNetworkMonitor(tab) {

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

@ -87,5 +87,5 @@ addRDMTask(
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -8,51 +8,47 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
const TEST_URL = `${URL_ROOT}page_style.html`;
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
// Store the RDM body text color for later.
const rdmWindow = ui.toolWindow;
const rdmTextColor = rdmWindow.getComputedStyle(rdmWindow.document.body)
.color;
addRDMTask(TEST_URL, async function({ ui, manager }) {
// Store the RDM body text color for later.
const rdmWindow = ui.toolWindow;
const rdmTextColor = rdmWindow.getComputedStyle(rdmWindow.document.body)
.color;
info(
"Trigger the no page style action and wait for the text color to change"
);
let onPageColorChanged = waitForContentPageTextColor(ui, "rgb(0, 0, 0)");
let menuItem = document.querySelector("#menu_pageStyleNoStyle");
menuItem.click();
let color = await onPageColorChanged;
info(
"Trigger the no page style action and wait for the text color to change"
);
let onPageColorChanged = waitForContentPageTextColor(ui, "rgb(0, 0, 0)");
let menuItem = document.querySelector("#menu_pageStyleNoStyle");
menuItem.click();
let color = await onPageColorChanged;
is(
color,
"rgb(0, 0, 0)",
"The text color is black, so the style was disabled"
);
is(
color,
"rgb(0, 0, 0)",
"The text color is black, so the style was disabled"
);
info("Check that the RDM page style wasn't disabled");
is(
rdmWindow.getComputedStyle(rdmWindow.document.body).color,
rdmTextColor,
"The color of the text in the RDM window is correct, so that style still applies"
);
info("Check that the RDM page style wasn't disabled");
is(
rdmWindow.getComputedStyle(rdmWindow.document.body).color,
rdmTextColor,
"The color of the text in the RDM window is correct, so that style still applies"
);
info(
"Trigger the page style back and wait for the text color to change again"
);
onPageColorChanged = waitForContentPageTextColor(ui, "rgb(255, 0, 0)");
menuItem = document.querySelector("#menu_pageStylePersistentOnly");
menuItem.click();
color = await onPageColorChanged;
info(
"Trigger the page style back and wait for the text color to change again"
);
onPageColorChanged = waitForContentPageTextColor(ui, "rgb(255, 0, 0)");
menuItem = document.querySelector("#menu_pageStylePersistentOnly");
menuItem.click();
color = await onPageColorChanged;
is(
color,
"rgb(255, 0, 0)",
"The text color is red, so the style was enabled"
);
},
{ usingBrowserUI: true }
);
is(
color,
"rgb(255, 0, 0)",
"The text color is red, so the style was enabled"
);
});
function waitForContentPageTextColor(ui, expectedColor) {
return SpecialPowers.spawn(

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

@ -63,5 +63,5 @@ addRDMTask(
await closeRDM(tab);
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -9,48 +9,44 @@
*/
const TEST_URI = `${URL_ROOT}doc_picker_link.html`;
addRDMTask(
TEST_URI,
async function({ ui, manager }) {
info("Open the rule-view and select the test node before opening RDM");
const { inspector, toolbox } = await openRuleView();
await selectNode("body", inspector);
addRDMTask(TEST_URI, async function({ ui, manager }) {
info("Open the rule-view and select the test node before opening RDM");
const { inspector, toolbox } = await openRuleView();
await selectNode("body", inspector);
info("Open RDM");
info("Open RDM");
// XXX: Using toggleTouchSimulation waits for browser loaded, which is not
// fired here?
info("Toggle Touch simulation");
const { document } = ui.toolWindow;
const touchButton = document.getElementById("touch-simulation-button");
const changed = once(ui, "touch-simulation-changed");
touchButton.click();
await changed;
// XXX: Using toggleTouchSimulation waits for browser loaded, which is not
// fired here?
info("Toggle Touch simulation");
const { document } = ui.toolWindow;
const touchButton = document.getElementById("touch-simulation-button");
const changed = once(ui, "touch-simulation-changed");
touchButton.click();
await changed;
info("Waiting for element picker to become active.");
await startPicker(toolbox, ui);
info("Waiting for element picker to become active.");
await startPicker(toolbox, ui);
info("Move mouse over the pick-target");
await hoverElement(inspector, ui, ".picker-link", 15, 15);
info("Move mouse over the pick-target");
await hoverElement(inspector, ui, ".picker-link", 15, 15);
// Add a listener on the "navigate" event.
let hasNavigated = false;
toolbox.target.once("navigate").then(() => {
hasNavigated = true;
});
// Add a listener on the "navigate" event.
let hasNavigated = false;
toolbox.target.once("navigate").then(() => {
hasNavigated = true;
});
info("Click and pick the link");
await pickElement(inspector, ui, ".picker-link");
info("Click and pick the link");
await pickElement(inspector, ui, ".picker-link");
// Wait until page to start navigation.
await wait(2000);
ok(
!hasNavigated,
"The page should not have navigated when picking the <a> element"
);
},
{ usingBrowserUI: true }
);
// Wait until page to start navigation.
await wait(2000);
ok(
!hasNavigated,
"The page should not have navigated when picking the <a> element"
);
});
/**
* startPicker, hoverElement and pickElement are slightly modified copies of

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

@ -32,5 +32,5 @@ addRDMTask(
await closeRDM(tab);
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -27,41 +27,37 @@ async function waitUntilScreenshot() {
});
}
addRDMTask(
TEST_URL,
async function({ ui }) {
const { toolWindow } = ui;
const { store, document } = toolWindow;
addRDMTask(TEST_URL, async function({ ui }) {
const { toolWindow } = ui;
const { store, document } = toolWindow;
info("Click the screenshot button");
const screenshotButton = document.getElementById("screenshot-button");
screenshotButton.click();
info("Click the screenshot button");
const screenshotButton = document.getElementById("screenshot-button");
screenshotButton.click();
const whenScreenshotSucceeded = waitUntilScreenshot();
const whenScreenshotSucceeded = waitUntilScreenshot();
const filePath = await whenScreenshotSucceeded;
const image = new Image();
image.src = OS.Path.toFileURI(filePath);
const filePath = await whenScreenshotSucceeded;
const image = new Image();
image.src = OS.Path.toFileURI(filePath);
await once(image, "load");
await once(image, "load");
// We have only one viewport at the moment
const viewport = store.getState().viewports[0];
const ratio = window.devicePixelRatio;
// We have only one viewport at the moment
const viewport = store.getState().viewports[0];
const ratio = window.devicePixelRatio;
is(
image.width,
viewport.width * ratio,
"screenshot width has the expected width"
);
is(
image.width,
viewport.width * ratio,
"screenshot width has the expected width"
);
is(
image.height,
viewport.height * ratio,
"screenshot width has the expected height"
);
is(
image.height,
viewport.height * ratio,
"screenshot width has the expected height"
);
await OS.File.remove(filePath);
},
{ usingBrowserUI: true }
);
await OS.File.remove(filePath);
});

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

@ -13,33 +13,29 @@ const TEST_URL =
'<head><meta name="viewport" content="width=100, height=100"/></head>' +
'<div style="background:blue; width:200px; height:200px"></div>';
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
await setViewportSize(ui, manager, 50, 50);
const browser = ui.getViewportBrowser();
addRDMTask(TEST_URL, async function({ ui, manager }) {
await setViewportSize(ui, manager, 50, 50);
const browser = ui.getViewportBrowser();
for (const mv in [true, false]) {
const reloadNeeded = await ui.updateTouchSimulation(mv);
if (reloadNeeded) {
info("Reload is needed -- waiting for it.");
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
}
info("Setting focus on the browser.");
browser.focus();
await SpecialPowers.spawn(browser, [], () => {
content.scrollTo(0, 0);
});
info("Testing scroll behavior with touch simulation " + mv + ".");
await testScrollingOfContent(ui);
for (const mv in [true, false]) {
const reloadNeeded = await ui.updateTouchSimulation(mv);
if (reloadNeeded) {
info("Reload is needed -- waiting for it.");
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
}
},
{ usingBrowserUI: true }
);
info("Setting focus on the browser.");
browser.focus();
await SpecialPowers.spawn(browser, [], () => {
content.scrollTo(0, 0);
});
info("Testing scroll behavior with touch simulation " + mv + ".");
await testScrollingOfContent(ui);
}
});
async function testScrollingOfContent(ui) {
let scroll;

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

@ -37,7 +37,7 @@ addRDMTask(
reloadOnTouchChange(false);
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -63,7 +63,7 @@ addRDMTask(
reloadOnTouchChange(false);
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
addRDMTask(
@ -86,5 +86,5 @@ addRDMTask(
reloadOnTouchChange(false);
reloadOnUAChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);

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

@ -28,7 +28,7 @@ addRDMTask(
await clientClosed;
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);
addRDMTask(
@ -49,5 +49,5 @@ addRDMTask(
await clientClosed;
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -43,7 +43,7 @@ addRDMTask(
await clientClosed;
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);
addRDMTask(
@ -71,5 +71,5 @@ addRDMTask(
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -11,9 +11,6 @@ const PAGE_ON_MAIN = "about:robots";
const TEST_DPPX = 2;
add_task(async function() {
// The target-switching only works with the new browserUI RDM.
await pushPref("devtools.responsive.browserUI.enabled", true);
// Set a pref for DPPX in order to assert whether the RDM is working correctly or not.
await pushPref("devtools.responsive.viewport.pixelRatio", TEST_DPPX);

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

@ -11,18 +11,14 @@ const TEST_URL = `data:text/html,<a href="${TAB_URL}" target="_blank">Click me</
"%20"
);
addRDMTask(
TEST_URL,
async function({ ui }) {
// Click the target="_blank" link and wait for a new tab
await waitForFrameLoad(ui, TEST_URL);
const newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, TAB_URL);
spawnViewportTask(ui, {}, function() {
content.document.querySelector("a").click(); // eslint-disable-line
});
const newTab = await newTabPromise;
ok(newTab, "New tab opened from link");
await removeTab(newTab);
},
{ usingBrowserUI: true }
);
addRDMTask(TEST_URL, async function({ ui }) {
// Click the target="_blank" link and wait for a new tab
await waitForFrameLoad(ui, TEST_URL);
const newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, TAB_URL);
spawnViewportTask(ui, {}, function() {
content.document.querySelector("a").click(); // eslint-disable-line
});
const newTab = await newTabPromise;
ok(newTab, "New tab opened from link");
await removeTab(newTab);
});

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

@ -69,7 +69,7 @@ addRDMTask(
await openCloseRDM(tab);
await checkResults();
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);
async function openCloseRDM(tab) {

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

@ -19,28 +19,22 @@ const TEST_URI =
"};" +
"</style><div></div></html>";
addRDMTask(
TEST_URI,
async function({ ui, manager }) {
info(
"Open the responsive design mode and set its size to 500x500 to start"
);
await setViewportSize(ui, manager, 500, 500);
addRDMTask(TEST_URI, async function({ ui, manager }) {
info("Open the responsive design mode and set its size to 500x500 to start");
await setViewportSize(ui, manager, 500, 500);
info("Open the inspector, computed-view and select the test node");
const { inspector, view } = await openComputedView();
await selectNode("div", inspector);
info("Open the inspector, computed-view and select the test node");
const { inspector, view } = await openComputedView();
await selectNode("div", inspector);
info("Try shrinking the viewport and checking the applied styles");
await testShrink(view, inspector, ui, manager);
info("Try shrinking the viewport and checking the applied styles");
await testShrink(view, inspector, ui, manager);
info("Try growing the viewport and checking the applied styles");
await testGrow(view, inspector, ui, manager);
info("Try growing the viewport and checking the applied styles");
await testGrow(view, inspector, ui, manager);
await closeToolbox();
},
{ usingBrowserUI: true }
);
await closeToolbox();
});
async function testShrink(computedView, inspector, ui, manager) {
is(computedWidth(computedView), "500px", "Should show 500px initially.");

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

@ -7,31 +7,25 @@
const TEST_URI = `${URL_ROOT}doc_toolbox_rule_view.html`;
addRDMTask(
TEST_URI,
async function({ ui, manager }) {
info(
"Open the responsive design mode and set its size to 500x500 to start"
);
await setViewportSize(ui, manager, 500, 500);
addRDMTask(TEST_URI, async function({ ui, manager }) {
info("Open the responsive design mode and set its size to 500x500 to start");
await setViewportSize(ui, manager, 500, 500);
info("Open the inspector, rule-view and select the test node");
const { inspector, view } = await openRuleView();
await selectNode("div", inspector);
info("Open the inspector, rule-view and select the test node");
const { inspector, view } = await openRuleView();
await selectNode("div", inspector);
info("Try shrinking the viewport and checking the applied styles");
await testShrink(view, ui, manager);
info("Try shrinking the viewport and checking the applied styles");
await testShrink(view, ui, manager);
info("Try growing the viewport and checking the applied styles");
await testGrow(view, ui, manager);
info("Try growing the viewport and checking the applied styles");
await testGrow(view, ui, manager);
info("Check that ESC still opens the split console");
await testEscapeOpensSplitConsole(inspector);
info("Check that ESC still opens the split console");
await testEscapeOpensSplitConsole(inspector);
await closeToolbox();
},
{ usingBrowserUI: true }
);
await closeToolbox();
});
async function testShrink(ruleView, ui, manager) {
is(numberOfRules(ruleView), 2, "Should have two rules initially.");

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

@ -48,8 +48,7 @@ addRDMTaskWithPreAndPost(
"Rule view still has two rules and is not empty."
);
},
null,
{ usingBrowserUI: true }
null
);
function numberOfRules(ruleView) {

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

@ -169,5 +169,5 @@ addRDMTask(
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -46,5 +46,5 @@ addRDMTask(
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -8,54 +8,50 @@ const TEST_URL = `data:text/html;charset=utf-8,${TEST_CONTENT}`;
// Test for the tooltip coordinate on the browsing document in RDM.
addRDMTask(
TEST_URL,
async ({ ui }) => {
// On ubuntu1804, the test fails if the real mouse cursor is on the test document.
// See Bug 1600183
info("Disable non test mouse event");
window.windowUtils.disableNonTestMouseEvents(true);
registerCleanupFunction(() => {
window.windowUtils.disableNonTestMouseEvents(false);
});
addRDMTask(TEST_URL, async ({ ui }) => {
// On ubuntu1804, the test fails if the real mouse cursor is on the test document.
// See Bug 1600183
info("Disable non test mouse event");
window.windowUtils.disableNonTestMouseEvents(true);
registerCleanupFunction(() => {
window.windowUtils.disableNonTestMouseEvents(false);
});
info("Create a promise which waits until the tooltip will be shown");
const tooltip = ui.browserWindow.gBrowser.ownerDocument.getElementById(
"remoteBrowserTooltip"
info("Create a promise which waits until the tooltip will be shown");
const tooltip = ui.browserWindow.gBrowser.ownerDocument.getElementById(
"remoteBrowserTooltip"
);
const onTooltipShown = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
info("Show a tooltip");
await spawnViewportTask(ui, {}, async () => {
const target = content.document.querySelector("h1");
await EventUtils.synthesizeMouse(
target,
1,
1,
{ type: "mouseover", isSynthesized: false },
content
);
const onTooltipShown = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
await EventUtils.synthesizeMouse(
target,
2,
1,
{ type: "mousemove", isSynthesized: false },
content
);
await EventUtils.synthesizeMouse(
target,
3,
1,
{ type: "mousemove", isSynthesized: false },
content
);
});
info("Show a tooltip");
await spawnViewportTask(ui, {}, async () => {
const target = content.document.querySelector("h1");
await EventUtils.synthesizeMouse(
target,
1,
1,
{ type: "mouseover", isSynthesized: false },
content
);
await EventUtils.synthesizeMouse(
target,
2,
1,
{ type: "mousemove", isSynthesized: false },
content
);
await EventUtils.synthesizeMouse(
target,
3,
1,
{ type: "mousemove", isSynthesized: false },
content
);
});
info("Wait for showing the tooltip");
await onTooltipShown;
info("Wait for showing the tooltip");
await onTooltipShown;
info("Test the X coordinate of the tooltip");
isnot(tooltip.screenX, 0, "The X coordinate of tooltip should not be 0");
},
{ usingBrowserUI: true }
);
info("Test the X coordinate of the tooltip");
isnot(tooltip.screenX, 0, "The X coordinate of tooltip should not be 0");
});

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

@ -38,7 +38,7 @@ addRDMTask(
reloadOnTouchChange(false);
},
{ usingBrowserUI: true, waitForDeviceList: true }
{ waitForDeviceList: true }
);
async function waitStartup(ui) {

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

@ -7,27 +7,23 @@
const TEST_URL = `${URL_ROOT}hover.html`;
addRDMTask(
TEST_URL,
async function({ ui }) {
reloadOnTouchChange(true);
addRDMTask(TEST_URL, async function({ ui }) {
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
await toggleTouchSimulation(ui);
info("Test element hover states when touch is enabled.");
await testButtonHoverState(ui, "rgb(255, 0, 0)");
await testDropDownHoverState(ui, "none");
info("Test element hover states when touch is enabled.");
await testButtonHoverState(ui, "rgb(255, 0, 0)");
await testDropDownHoverState(ui, "none");
await toggleTouchSimulation(ui);
await toggleTouchSimulation(ui);
info("Test element hover states when touch is disabled.");
await testButtonHoverState(ui, "rgb(0, 0, 0)");
await testDropDownHoverState(ui, "block");
info("Test element hover states when touch is disabled.");
await testButtonHoverState(ui, "rgb(0, 0, 0)");
await testDropDownHoverState(ui, "block");
reloadOnTouchChange(false);
},
{ usingBrowserUI: true }
);
reloadOnTouchChange(false);
});
async function testButtonHoverState(ui, expected) {
await SpecialPowers.spawn(

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

@ -7,54 +7,45 @@
const TEST_URL = `${URL_ROOT}touch_event_bubbles.html`;
addRDMTask(
TEST_URL,
async function({ ui }) {
info("Toggling on touch simulation.");
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
addRDMTask(TEST_URL, async function({ ui }) {
info("Toggling on touch simulation.");
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
info("Test that touch event bubbles.");
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
const outerDiv = content.document.getElementById("outer");
const span = content.document.querySelector("span");
info("Test that touch event bubbles.");
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {
const outerDiv = content.document.getElementById("outer");
const span = content.document.querySelector("span");
outerDiv.addEventListener("touchstart", () => {
span.style["background-color"] = "green"; // rgb(0, 128, 0)
});
const touchStartPromise = ContentTaskUtils.waitForEvent(
span,
"touchstart"
);
await EventUtils.synthesizeMouseAtCenter(
span,
{ type: "mousedown", isSynthesized: false },
content
);
await touchStartPromise;
const win = content.document.defaultView;
const bg = win
.getComputedStyle(span)
.getPropertyValue("background-color");
is(
bg,
"rgb(0, 128, 0)",
`span's background color should be rgb(0, 128, 0): got ${bg}`
);
await EventUtils.synthesizeMouseAtCenter(
span,
{ type: "mouseup", isSynthesized: false },
content
);
outerDiv.addEventListener("touchstart", () => {
span.style["background-color"] = "green"; // rgb(0, 128, 0)
});
info("Toggling off touch simulation.");
await toggleTouchSimulation(ui);
reloadOnTouchChange(false);
},
{ usingBrowserUI: true }
);
const touchStartPromise = ContentTaskUtils.waitForEvent(span, "touchstart");
await EventUtils.synthesizeMouseAtCenter(
span,
{ type: "mousedown", isSynthesized: false },
content
);
await touchStartPromise;
const win = content.document.defaultView;
const bg = win.getComputedStyle(span).getPropertyValue("background-color");
is(
bg,
"rgb(0, 128, 0)",
`span's background color should be rgb(0, 128, 0): got ${bg}`
);
await EventUtils.synthesizeMouseAtCenter(
span,
{ type: "mouseup", isSynthesized: false },
content
);
});
info("Toggling off touch simulation.");
await toggleTouchSimulation(ui);
reloadOnTouchChange(false);
});

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

@ -10,21 +10,17 @@ const TEST_URL =
'<div style="width:100px;height:100px;background-color:red"></div>' +
"</body>";
addRDMTask(
TEST_URL,
async function({ ui }) {
info("Toggling on touch simulation.");
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
addRDMTask(TEST_URL, async function({ ui }) {
info("Toggling on touch simulation.");
reloadOnTouchChange(true);
await toggleTouchSimulation(ui);
await testPointerEvents(ui);
await testPointerEvents(ui);
info("Toggling off touch simulation.");
await toggleTouchSimulation(ui);
reloadOnTouchChange(false);
},
{ usingBrowserUI: true }
);
info("Toggling off touch simulation.");
await toggleTouchSimulation(ui);
reloadOnTouchChange(false);
});
async function testPointerEvents(ui) {
info("Test that pointer events are from touch events");

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

@ -12,24 +12,20 @@ const PREF_DOM_META_VIEWPORT_ENABLED = "dom.meta-viewport.enabled";
// is allowed.
const DELAY = 300;
addRDMTask(
TEST_URL,
async function({ ui }) {
reloadOnTouchChange(true);
addRDMTask(TEST_URL, async function({ ui }) {
reloadOnTouchChange(true);
await waitBootstrap(ui);
await testWithNoTouch(ui);
await toggleTouchSimulation(ui);
await promiseContentReflow(ui);
await testWithTouch(ui);
await testWithMetaViewportEnabled(ui);
await testWithMetaViewportDisabled(ui);
testTouchButton(ui);
await waitBootstrap(ui);
await testWithNoTouch(ui);
await toggleTouchSimulation(ui);
await promiseContentReflow(ui);
await testWithTouch(ui);
await testWithMetaViewportEnabled(ui);
await testWithMetaViewportDisabled(ui);
testTouchButton(ui);
reloadOnTouchChange(false);
},
{ usingBrowserUI: true }
);
reloadOnTouchChange(false);
});
async function testWithNoTouch(ui) {
await SpecialPowers.spawn(ui.getViewportBrowser(), [], async function() {

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

@ -17,58 +17,54 @@ const TEST_URL =
"data:text/html;charset=utf-8," +
'<body id="body"><input id="input" type="text"/><p>text</body>';
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
// Turn on the pref that allows meta viewport support.
await pushPref("accessibility.typeaheadfind", true);
addRDMTask(TEST_URL, async function({ ui, manager }) {
// Turn on the pref that allows meta viewport support.
await pushPref("accessibility.typeaheadfind", true);
const browser = ui.getViewportBrowser();
const browser = ui.getViewportBrowser();
info("--- Starting test output ---");
info("--- Starting test output ---");
const expected = [
{
id: "body",
findTriggered: true,
},
{
id: "input",
findTriggered: false,
},
];
const expected = [
{
id: "body",
findTriggered: true,
},
{
id: "input",
findTriggered: false,
},
];
for (const e of expected) {
await SpecialPowers.spawn(browser, [{ e }], async function(args) {
const { e: values } = args;
const element = content.document.getElementById(values.id);
for (const e of expected) {
await SpecialPowers.spawn(browser, [{ e }], async function(args) {
const { e: values } = args;
const element = content.document.getElementById(values.id);
// Set focus on the desired element.
element.focus();
});
// Set focus on the desired element.
element.focus();
});
// Press the 'T' key and see if find is triggered.
await BrowserTestUtils.synthesizeKey("t", {}, browser);
// Press the 'T' key and see if find is triggered.
await BrowserTestUtils.synthesizeKey("t", {}, browser);
const findBar = await gBrowser.getFindBar();
const findBar = await gBrowser.getFindBar();
const findIsTriggered = findBar._findField.value == "t";
is(
findIsTriggered,
e.findTriggered,
"Text input with focused element " +
e.id +
" should " +
(e.findTriggered ? "" : "not ") +
"trigger find."
);
findBar._findField.value = "";
const findIsTriggered = findBar._findField.value == "t";
is(
findIsTriggered,
e.findTriggered,
"Text input with focused element " +
e.id +
" should " +
(e.findTriggered ? "" : "not ") +
"trigger find."
);
findBar._findField.value = "";
await SpecialPowers.spawn(browser, [], async function() {
// Clear focus.
content.document.activeElement.blur();
});
}
},
{ usingBrowserUI: true }
);
await SpecialPowers.spawn(browser, [], async function() {
// Clear focus.
content.document.activeElement.blur();
});
}
});

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

@ -6,23 +6,19 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
const TEST_URL = "data:text/html;charset=utf-8,";
const NEW_USER_AGENT = "Mozilla/5.0 (Mobile; rv:39.0) Gecko/39.0 Firefox/39.0";
addRDMTask(
TEST_URL,
async function({ ui }) {
reloadOnUAChange(true);
addRDMTask(TEST_URL, async function({ ui }) {
reloadOnUAChange(true);
info("Check the default state of the user agent input");
await testUserAgent(ui, DEFAULT_UA);
info("Check the default state of the user agent input");
await testUserAgent(ui, DEFAULT_UA);
info(`Change the user agent input to ${NEW_USER_AGENT}`);
await changeUserAgentInput(ui, NEW_USER_AGENT);
await testUserAgent(ui, NEW_USER_AGENT);
info(`Change the user agent input to ${NEW_USER_AGENT}`);
await changeUserAgentInput(ui, NEW_USER_AGENT);
await testUserAgent(ui, NEW_USER_AGENT);
info("Reset the user agent input back to the default UA");
await changeUserAgentInput(ui, "");
await testUserAgent(ui, DEFAULT_UA);
info("Reset the user agent input back to the default UA");
await changeUserAgentInput(ui, "");
await testUserAgent(ui, DEFAULT_UA);
reloadOnUAChange(false);
},
{ usingBrowserUI: true }
);
reloadOnUAChange(false);
});

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

@ -6,28 +6,24 @@
// Test viewports basics after opening, like size and location
const TEST_URL = "http://example.org/";
addRDMTask(
TEST_URL,
async function({ ui }) {
const browser = ui.getViewportBrowser();
addRDMTask(TEST_URL, async function({ ui }) {
const browser = ui.getViewportBrowser();
is(
ui.toolWindow.getComputedStyle(browser).getPropertyValue("width"),
"320px",
"Viewport has default width"
);
is(
ui.toolWindow.getComputedStyle(browser).getPropertyValue("height"),
"480px",
"Viewport has default height"
);
is(
ui.toolWindow.getComputedStyle(browser).getPropertyValue("width"),
"320px",
"Viewport has default width"
);
is(
ui.toolWindow.getComputedStyle(browser).getPropertyValue("height"),
"480px",
"Viewport has default height"
);
// Browser's location should match original tab
await load(browser, TEST_URL);
const location = await spawnViewportTask(ui, {}, function() {
return content.location.href; // eslint-disable-line
});
is(location, TEST_URL, "Viewport location matches");
},
{ usingBrowserUI: true }
);
// Browser's location should match original tab
await load(browser, TEST_URL);
const location = await spawnViewportTask(ui, {}, function() {
return content.location.href; // eslint-disable-line
});
is(location, TEST_URL, "Viewport location matches");
});

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

@ -70,60 +70,56 @@ const TEST_URL =
`<div id="box" style="width:400px;height:400px;background-color:green">` +
`Initial</div></body></html>`;
addRDMTask(
TEST_URL,
async function({ ui, manager, browser }) {
await setViewportSize(ui, manager, WIDTH, HEIGHT);
await setTouchAndMetaViewportSupport(ui, true);
addRDMTask(TEST_URL, async function({ ui, manager, browser }) {
await setViewportSize(ui, manager, WIDTH, HEIGHT);
await setTouchAndMetaViewportSupport(ui, true);
// Check initial resolution value.
const initial_resolution = await spawnViewportTask(ui, {}, () => {
// Check initial resolution value.
const initial_resolution = await spawnViewportTask(ui, {}, () => {
return content.windowUtils.getResolution();
});
is(
initial_resolution.toFixed(2),
INITIAL_RES_TARGET.toFixed(2),
`Initial resolution is as expected.`
);
for (const test of TESTS) {
const { content: content, res_target, res_chrome } = test;
await spawnViewportTask(ui, { content }, args => {
const box = content.document.getElementById("box");
box.textContent = args.content;
const meta = content.document.getElementsByTagName("meta")[0];
info(`Changing meta viewport content to "${args.content}".`);
meta.content = args.content;
});
await promiseContentReflow(ui);
const resolution = await spawnViewportTask(ui, {}, () => {
return content.windowUtils.getResolution();
});
is(
initial_resolution.toFixed(2),
INITIAL_RES_TARGET.toFixed(2),
`Initial resolution is as expected.`
resolution.toFixed(2),
res_target.toFixed(2),
`Replaced meta viewport content "${content}" resolution is as expected.`
);
for (const test of TESTS) {
const { content: content, res_target, res_chrome } = test;
await spawnViewportTask(ui, { content }, args => {
const box = content.document.getElementById("box");
box.textContent = args.content;
const meta = content.document.getElementsByTagName("meta")[0];
info(`Changing meta viewport content to "${args.content}".`);
meta.content = args.content;
});
await promiseContentReflow(ui);
const resolution = await spawnViewportTask(ui, {}, () => {
return content.windowUtils.getResolution();
});
is(
if (typeof res_chrome !== "undefined") {
todo_is(
resolution.toFixed(2),
res_target.toFixed(2),
`Replaced meta viewport content "${content}" resolution is as expected.`
res_chrome.toFixed(2),
`Replaced meta viewport content "${content}" resolution matches Chrome resolution.`
);
if (typeof res_chrome !== "undefined") {
todo_is(
resolution.toFixed(2),
res_chrome.toFixed(2),
`Replaced meta viewport content "${content}" resolution matches Chrome resolution.`
);
}
// Reload to prepare for next test.
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
}
},
{ usingBrowserUI: true }
);
// Reload to prepare for next test.
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
}
});

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

@ -13,83 +13,79 @@ const TEST_URL =
'<div style="width:100%;height:1100px;background-color:lightblue"></div>' +
"</body>";
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
addRDMTask(TEST_URL, async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// We're going to take a 300,600 viewport (before), reload it,
// then resize it to 600,300 (after) and then resize it back.
// At the before and after points, we'll measure zoom and the
// layout viewport width and height.
const expected = [
{
metaSupport: false,
before: [1.0, 300, 600],
after: [1.0, 600, 300],
},
{
metaSupport: true,
before: [0.5, 300, 600],
after: [1.0, 600, 300],
},
];
// We're going to take a 300,600 viewport (before), reload it,
// then resize it to 600,300 (after) and then resize it back.
// At the before and after points, we'll measure zoom and the
// layout viewport width and height.
const expected = [
{
metaSupport: false,
before: [1.0, 300, 600],
after: [1.0, 600, 300],
},
{
metaSupport: true,
before: [0.5, 300, 600],
after: [1.0, 600, 300],
},
];
for (const e of expected) {
const b = e.before;
const a = e.after;
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Force a reload.
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
// Force a reload.
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
// Check initial values again.
await testViewportZoomWidthAndHeight(
message + " after reload",
ui,
b[0],
b[1],
b[2]
);
// Check initial values again.
await testViewportZoomWidthAndHeight(
message + " after reload",
ui,
b[0],
b[1],
b[2]
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
},
{ usingBrowserUI: true }
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
});

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

@ -9,68 +9,64 @@ const TEST_URL =
"data:text/html;charset=utf-8," +
'<head><meta name="viewport" content="width=300"/></head>' +
"<body>meta viewport width 300</body>";
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
addRDMTask(TEST_URL, async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// We're going to take a 600,300 viewport (before) and resize it
// to 50,50 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
metaSupport: false,
before: [1.0, 600, 300],
after: [1.0, 50, 50], // Zoom is unaffected.
},
{
metaSupport: true,
before: [2.0, 300, 150],
after: [0.25, 300, 300], // This checks that min-zoom is active.
},
];
// We're going to take a 600,300 viewport (before) and resize it
// to 50,50 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
metaSupport: false,
before: [1.0, 600, 300],
after: [1.0, 50, 50], // Zoom is unaffected.
},
{
metaSupport: true,
before: [2.0, 300, 150],
after: [0.25, 300, 300], // This checks that min-zoom is active.
},
];
for (const e of expected) {
const b = e.before;
const a = e.after;
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 50, 50);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 50, 50);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
},
{ usingBrowserUI: true }
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
});

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

@ -10,84 +10,80 @@ const TEST_URL =
'<head><meta name="viewport" content="width=device-width, ' +
'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"></head>' +
"<body>meta viewport scaled locked at 1.0</body>";
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
addRDMTask(TEST_URL, async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// We're going to take a 300,600 viewport (before) and resize it
// to 600,300 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
metaSupport: false,
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
// We're going to take a 300,600 viewport (before) and resize it
// to 600,300 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
metaSupport: false,
before: {
zoom: 1.0,
width: 300,
height: 600,
},
{
metaSupport: true,
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
];
},
{
metaSupport: true,
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
},
];
for (const e of expected) {
const b = e.before;
const a = e.after;
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b.zoom,
b.width,
b.height
);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b.zoom,
b.width,
b.height
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a.zoom,
a.width,
a.height
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a.zoom,
a.width,
a.height
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
},
{ usingBrowserUI: true }
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
});

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

@ -11,70 +11,66 @@ const TEST_URL =
'minimum-scale=1.0, width=device-width"></head>' +
'<div style="width:100%;background-color:green">test</div>' +
"</body>";
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
addRDMTask(TEST_URL, async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// We're going to take a 300,600 viewport (before) and resize it
// to 600,300 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
// We're going to take a 300,600 viewport (before) and resize it
// to 600,300 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
before: {
zoom: 1.0,
width: 300,
height: 600,
},
];
after: {
zoom: 1.0,
width: 600,
height: 300,
},
},
];
for (const e of expected) {
const b = e.before;
const a = e.after;
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport ON";
const message = "Meta Viewport ON";
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, true);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, true);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b.zoom,
b.width,
b.height
);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b.zoom,
b.width,
b.height
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a.zoom,
a.width,
a.height
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a.zoom,
a.width,
a.height
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
},
{ usingBrowserUI: true }
);
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
});

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

@ -48,49 +48,45 @@ const TEST_URL =
"</head>" +
'<body><div style="background:orange; width:1000px; height:1000px"></div></body>';
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
// Turn on the prefs that force overlay scrollbars to always be visible, and to allow
// data URIs to be considered as same-origin.
await SpecialPowers.pushPrefEnv({
set: [
["layout.testing.overlay-scrollbars.always-visible", true],
["security.data_uri.unique_opaque_origin", false],
],
});
addRDMTask(TEST_URL, async function({ ui, manager }) {
// Turn on the prefs that force overlay scrollbars to always be visible, and to allow
// data URIs to be considered as same-origin.
await SpecialPowers.pushPrefEnv({
set: [
["layout.testing.overlay-scrollbars.always-visible", true],
["security.data_uri.unique_opaque_origin", false],
],
});
info("--- Starting viewport test output ---");
info("--- Starting viewport test output ---");
const browser = ui.getViewportBrowser();
const browser = ui.getViewportBrowser();
const expected = [false, true];
for (const e of expected) {
const message = "Meta Viewport " + (e ? "ON" : "OFF");
const expected = [false, true];
for (const e of expected) {
const message = "Meta Viewport " + (e ? "ON" : "OFF");
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Get to the initial size and snapshot the window.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
const initialSnapshot = await snapshotWindow(browser);
// Get to the initial size and snapshot the window.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
const initialSnapshot = await snapshotWindow(browser);
// Move to the rotated size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
// Move to the rotated size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
// Reload the window.
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
// Reload the window.
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
// Go back to the initial size and take another snapshot.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
const finalSnapshot = await snapshotWindow(browser);
// Go back to the initial size and take another snapshot.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
const finalSnapshot = await snapshotWindow(browser);
const result = compareSnapshots(initialSnapshot, finalSnapshot, true);
is(result[2], result[1], "Window snapshots should match.");
}
},
{ usingBrowserUI: true }
);
const result = compareSnapshots(initialSnapshot, finalSnapshot, true);
is(result[2], result[1], "Window snapshots should match.");
}
});

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

@ -32,10 +32,7 @@ for (const { content, res_restore } of TESTS) {
addRDMTaskWithPreAndPost(
TEST_URL,
async function rdmPreTask({ browser, usingBrowserUI }) {
info(
`Using meta viewport content "${content}" with new RDM UI ${usingBrowserUI}.`
);
async function rdmPreTask({ browser }) {
if (res_restore) {
info(`Setting resolution to ${res_restore}.`);
browser.ownerGlobal.windowUtils.setResolutionAndScaleTo(res_restore);
@ -43,12 +40,12 @@ for (const { content, res_restore } of TESTS) {
info(`Not setting resolution.`);
}
},
async function rdmTask({ ui, manager, browser, usingBrowserUI }) {
async function rdmTask({ ui, manager }) {
info(`Resizing viewport and ensuring that meta viewport is on.`);
await setViewportSize(ui, manager, WIDTH, HEIGHT);
await setTouchAndMetaViewportSupport(ui, true);
},
async function rdmPostTask({ browser, usingBrowserUI }) {
async function rdmPostTask({ browser }) {
const resolution = browser.ownerGlobal.windowUtils.getResolution();
const res_target = res_restore ? res_restore : 1.0;
@ -58,7 +55,6 @@ for (const { content, res_restore } of TESTS) {
res_min <= resolution && res_max >= resolution,
`${content} resolution should be near ${res_target}, and we got ${resolution}.`
);
},
{ usingBrowserUI: true }
}
);
}

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

@ -46,36 +46,28 @@ for (const { content, res_target } of TESTS) {
`<body><div style="width:100%;background-color:green">${content}</div>` +
`</body></html>`;
addRDMTask(
TEST_URL,
async function({ ui, manager, browser, usingBrowserUI }) {
info(
`Using meta viewport content "${content}" with new RDM UI ${usingBrowserUI}.`
addRDMTask(TEST_URL, async function({ ui, manager, browser }) {
await setViewportSize(ui, manager, WIDTH, HEIGHT);
await setTouchAndMetaViewportSupport(ui, true);
// Ensure we've reflowed the page at least once so that MVM has chosen
// the initial scale.
await promiseContentReflow(ui);
for (const zoom of ZOOM_LEVELS.concat([...ZOOM_LEVELS].reverse())) {
info(`Set zoom to ${zoom}.`);
await promiseRDMZoom(ui, browser, zoom);
const resolution = await spawnViewportTask(ui, {}, () => {
return content.windowUtils.getResolution();
});
const res_min = res_target * RESOLUTION_FACTOR_MIN;
const res_max = res_target * RESOLUTION_FACTOR_MAX;
ok(
res_min <= resolution && res_max >= resolution,
`${content} zoom ${zoom} resolution should be near ${res_target}, and we got ${resolution}.`
);
await setViewportSize(ui, manager, WIDTH, HEIGHT);
await setTouchAndMetaViewportSupport(ui, true);
// Ensure we've reflowed the page at least once so that MVM has chosen
// the initial scale.
await promiseContentReflow(ui);
for (const zoom of ZOOM_LEVELS.concat([...ZOOM_LEVELS].reverse())) {
info(`Set zoom to ${zoom}.`);
await promiseRDMZoom(ui, browser, zoom);
const resolution = await spawnViewportTask(ui, {}, () => {
return content.windowUtils.getResolution();
});
const res_min = res_target * RESOLUTION_FACTOR_MIN;
const res_max = res_target * RESOLUTION_FACTOR_MAX;
ok(
res_min <= resolution && res_max >= resolution,
`${content} zoom ${zoom} resolution should be near ${res_target}, and we got ${resolution}.`
);
}
},
{ usingBrowserUI: true }
);
}
});
}

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

@ -97,5 +97,5 @@ addRDMTask(
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -28,5 +28,5 @@ addRDMTask(
await BrowserTestUtils.closeWindow(newWindow);
await offPromise;
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);

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

@ -31,7 +31,7 @@ addRDMTask(
await checkWindowScreenSize(ui, ZOOM_LEVELS[i]);
}
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
{ onlyPrefAndTask: true }
);
async function checkWindowOuterSize(ui, zoom_level) {

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

@ -135,8 +135,6 @@ var closeRDM = async function(tab, options) {
* removes the tab. The final argument is an options object, with these
* optional properties:
*
* usingBrowserUI: the devtools.responsive.browserUI.enabled pref is set
* to the truthiness of this value (default false).
* onlyPrefAndTask: if truthy, only the pref will be set and the task
* will be called, with none of the tab creation/teardown or open/close
* of RDM (default false).
@ -147,36 +145,27 @@ var closeRDM = async function(tab, options) {
*
* addRDMTaskWithPreAndPost(
* TEST_URL,
* async function preTask({ message, browser, usingBrowserUI }) {
* async function preTask({ message, browser }) {
* // Your pre-task goes here...
* },
* async function task({ ui, manager, message, browser, usingBrowserUI,
* preTaskValue }) {
* async function task({ ui, manager, message, browser, preTaskValue }) {
* // Your task goes here...
* },
* async function postTask({ message, browser, usingBrowserUI,
* preTaskValue, taskValue }) {
* async function postTask({ message, browser, preTaskValue, taskValue }) {
* // Your post-task goes here...
* },
* { usingBrowserUI: true, waitForDeviceList: true }
* { waitForDeviceList: true }
* );
*/
function addRDMTaskWithPreAndPost(url, preTask, task, postTask, options) {
// Interpret our options.
let usingBrowserUI = false;
let onlyPrefAndTask = false;
let waitForDeviceList = false;
if (typeof options == "object") {
usingBrowserUI = !!options.usingBrowserUI;
onlyPrefAndTask = !!options.onlyPrefAndTask;
waitForDeviceList = !!options.waitForDeviceList;
}
add_task(async function() {
await SpecialPowers.pushPrefEnv({
set: [["devtools.responsive.browserUI.enabled", usingBrowserUI]],
});
let tab;
let browser;
let preTaskValue = null;
@ -189,7 +178,7 @@ function addRDMTaskWithPreAndPost(url, preTask, task, postTask, options) {
browser = tab.linkedBrowser;
if (preTask) {
preTaskValue = await preTask({ message, browser, usingBrowserUI });
preTaskValue = await preTask({ message, browser });
}
const rdmValues = await openRDM(tab);
@ -218,17 +207,10 @@ function addRDMTaskWithPreAndPost(url, preTask, task, postTask, options) {
manager,
message,
browser,
usingBrowserUI,
preTaskValue,
});
} catch (err) {
ok(
false,
"Got an error with usingBrowserUI " +
usingBrowserUI +
": " +
DevToolsUtils.safeErrorString(err)
);
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(err));
}
if (!onlyPrefAndTask) {
@ -237,7 +219,6 @@ function addRDMTaskWithPreAndPost(url, preTask, task, postTask, options) {
await postTask({
message,
browser,
usingBrowserUI,
preTaskValue,
taskValue,
});
@ -254,18 +235,16 @@ function addRDMTaskWithPreAndPost(url, preTask, task, postTask, options) {
/**
* This is a simplified version of addRDMTaskWithPreAndPost. Adds a new test
* task that adds a tab with the given URL, opens responsive design mode,
* closes responsive design mode, and removes the tab. If
* includeBrowserEmbeddedUI is truthy, the sequence will be repeated with the
* devtools.responsive.browserUI.enabled pref set.
* closes responsive design mode, and removes the tab.
*
* Example usage:
*
* addRDMTask(
* TEST_URL,
* async function task({ ui, manager, message, browser, usingBrowserUI }) {
* async function task({ ui, manager, message, browser }) {
* // Your task goes here...
* },
* { usingBrowserUI: true, waitForDeviceList: true }
* { waitForDeviceList: true }
* );
*/
function addRDMTask(rdmURL, rdmTask, options) {