Files
firefox/devtools/client/shared/test/browser_devices.js
T
J. Ryan Stinnett 530b903fcf Bug 1271084 - Apply ESLint autofixes to ignored /devtools files. r=tromey
For simple rules like function spacing, we can auto-fix these across the code
base so they are followed in a consistent way.

To generate this patch, I ran:

./mach eslint devtools --no-ignore --fix

After this, I reverted any changes to third party files that we really do want
to ignore.

MozReview-Commit-ID: 6Q8BApkAW20
2016-05-18 12:49:23 -05:00

51 lines
1.4 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var { GetDevices, GetDeviceString, AddDevice } = require("devtools/client/shared/devices");
add_task(function* () {
Services.prefs.setCharPref("devtools.devices.url", TEST_URI_ROOT + "browser_devices.json");
let devices = yield GetDevices();
is(devices.TYPES.length, 1, "Found 1 device type.");
let type1 = devices.TYPES[0];
is(devices[type1].length, 2, "Found 2 devices of type #1.");
let string = GetDeviceString(type1);
ok(typeof string === "string" && string.length > 0, "Able to localize type #1.");
let device1 = {
name: "SquarePhone",
width: 320,
height: 320,
pixelRatio: 2,
userAgent: "Mozilla/5.0 (Mobile; rv:42.0)",
touch: true,
firefoxOS: true
};
AddDevice(device1, type1);
devices = yield GetDevices();
is(devices[type1].length, 3, "Added new device of type #1.");
ok(devices[type1].filter(d => d.name === device1.name), "Found the new device.");
let type2 = "appliances";
let device2 = {
name: "Mr Freezer",
width: 800,
height: 600,
pixelRatio: 5,
userAgent: "Mozilla/5.0 (Appliance; rv:42.0)",
touch: true,
firefoxOS: true
};
AddDevice(device2, type2);
devices = yield GetDevices();
is(devices.TYPES.length, 2, "Added device type #2.");
is(devices[type2].length, 1, "Added new device of type #2.");
});