From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- devtools/client/shared/test/browser_devices.js | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 devtools/client/shared/test/browser_devices.js (limited to 'devtools/client/shared/test/browser_devices.js') diff --git a/devtools/client/shared/test/browser_devices.js b/devtools/client/shared/test/browser_devices.js new file mode 100644 index 0000000000..35a68d2714 --- /dev/null +++ b/devtools/client/shared/test/browser_devices.js @@ -0,0 +1,76 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { + getDevices, + getDeviceString, + addDevice, +} = require("resource://devtools/client/shared/devices.js"); + +add_task(async function () { + let devices = await getDevices(); + + let types = [...devices.keys()]; + ok(!!types.length, `Found ${types.length} device types.`); + + for (const type of types) { + const string = getDeviceString(type); + ok( + typeof string === "string" && + !!string.length && + string != `device.${type}`, + `Able to localize "${type}": "${string}"` + ); + + ok( + !!devices.get(type).length, + `Found ${devices.get(type).length} ${type} devices` + ); + } + + const type1 = types[0]; + const type1DeviceCount = devices.get(type1).length; + + const device1 = { + name: "SquarePhone", + width: 320, + height: 320, + pixelRatio: 2, + userAgent: "Mozilla/5.0 (Mobile; rv:42.0)", + touch: true, + firefoxOS: true, + }; + addDevice(device1, types[0]); + devices = await getDevices(); + + is( + devices.get(type1).length, + type1DeviceCount + 1, + `Added new device of type "${type1}".` + ); + ok( + devices.get(type1).find(d => d.name === device1.name), + "Found the new device." + ); + + const type2 = "appliances"; + const device2 = { + name: "Mr Freezer", + width: 800, + height: 600, + pixelRatio: 5, + userAgent: "Mozilla/5.0 (Appliance; rv:42.0)", + touch: true, + firefoxOS: true, + }; + + const typeCount = types.length; + addDevice(device2, type2); + devices = await getDevices(); + types = [...devices.keys()]; + + is(types.length, typeCount + 1, `Added device type "${type2}".`); + is(devices.get(type2).length, 1, `Added new "${type2}" device`); +}); -- cgit v1.2.3