From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../client/responsive.html/test/unit/.eslintrc.js | 6 ++++ devtools/client/responsive.html/test/unit/head.js | 21 +++++++++++ .../responsive.html/test/unit/test_add_device.js | 35 ++++++++++++++++++ .../test/unit/test_add_device_type.js | 22 ++++++++++++ .../responsive.html/test/unit/test_add_viewport.js | 23 ++++++++++++ .../test/unit/test_change_device.js | 42 ++++++++++++++++++++++ .../test/unit/test_change_display_pixel_ratio.js | 22 ++++++++++++ .../test/unit/test_change_location.js | 22 ++++++++++++ .../test/unit/test_change_network_throttling.js | 27 ++++++++++++++ .../test/unit/test_change_pixel_ratio.js | 22 ++++++++++++ .../test/unit/test_resize_viewport.js | 21 +++++++++++ .../test/unit/test_rotate_viewport.js | 25 +++++++++++++ .../test/unit/test_update_device_displayed.js | 37 +++++++++++++++++++ .../unit/test_update_touch_simulation_enabled.js | 23 ++++++++++++ .../client/responsive.html/test/unit/xpcshell.ini | 18 ++++++++++ 15 files changed, 366 insertions(+) create mode 100644 devtools/client/responsive.html/test/unit/.eslintrc.js create mode 100644 devtools/client/responsive.html/test/unit/head.js create mode 100644 devtools/client/responsive.html/test/unit/test_add_device.js create mode 100644 devtools/client/responsive.html/test/unit/test_add_device_type.js create mode 100644 devtools/client/responsive.html/test/unit/test_add_viewport.js create mode 100644 devtools/client/responsive.html/test/unit/test_change_device.js create mode 100644 devtools/client/responsive.html/test/unit/test_change_display_pixel_ratio.js create mode 100644 devtools/client/responsive.html/test/unit/test_change_location.js create mode 100644 devtools/client/responsive.html/test/unit/test_change_network_throttling.js create mode 100644 devtools/client/responsive.html/test/unit/test_change_pixel_ratio.js create mode 100644 devtools/client/responsive.html/test/unit/test_resize_viewport.js create mode 100644 devtools/client/responsive.html/test/unit/test_rotate_viewport.js create mode 100644 devtools/client/responsive.html/test/unit/test_update_device_displayed.js create mode 100644 devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js create mode 100644 devtools/client/responsive.html/test/unit/xpcshell.ini (limited to 'devtools/client/responsive.html/test/unit') diff --git a/devtools/client/responsive.html/test/unit/.eslintrc.js b/devtools/client/responsive.html/test/unit/.eslintrc.js new file mode 100644 index 000000000..f879b967b --- /dev/null +++ b/devtools/client/responsive.html/test/unit/.eslintrc.js @@ -0,0 +1,6 @@ +"use strict"; + +module.exports = { + // Extend from the shared list of defined globals for xpcshell. + "extends": "../../../../.eslintrc.xpcshell.js" +}; diff --git a/devtools/client/responsive.html/test/unit/head.js b/devtools/client/responsive.html/test/unit/head.js new file mode 100644 index 000000000..9c8dbffc4 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/head.js @@ -0,0 +1,21 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* eslint no-unused-vars: [2, {"vars": "local"}] */ + +const { utils: Cu } = Components; +const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); + +const promise = require("promise"); +const { Task } = require("devtools/shared/task"); +const Store = require("devtools/client/responsive.html/store"); + +const DevToolsUtils = require("devtools/shared/DevToolsUtils"); + +const flags = require("devtools/shared/flags"); +flags.testing = true; +do_register_cleanup(() => { + flags.testing = false; +}); diff --git a/devtools/client/responsive.html/test/unit/test_add_device.js b/devtools/client/responsive.html/test/unit/test_add_device.js new file mode 100644 index 000000000..0a16d3cf4 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_add_device.js @@ -0,0 +1,35 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test adding a new device. + +const { + addDevice, + addDeviceType, +} = require("devtools/client/responsive.html/actions/devices"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + let device = { + "name": "Firefox OS Flame", + "width": 320, + "height": 570, + "pixelRatio": 1.5, + "userAgent": "Mozilla/5.0 (Mobile; rv:39.0) Gecko/39.0 Firefox/39.0", + "touch": true, + "firefoxOS": true, + "os": "fxos" + }; + + dispatch(addDeviceType("phones")); + dispatch(addDevice(device, "phones")); + + equal(getState().devices.phones.length, 1, + "Correct number of phones"); + ok(getState().devices.phones.includes(device), + "Device phone list contains Firefox OS Flame"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_add_device_type.js b/devtools/client/responsive.html/test/unit/test_add_device_type.js new file mode 100644 index 000000000..1c8c65be3 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_add_device_type.js @@ -0,0 +1,22 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test adding a new device type. + +const { addDeviceType } = + require("devtools/client/responsive.html/actions/devices"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + dispatch(addDeviceType("phones")); + + equal(getState().devices.types.length, 1, "Correct number of device types"); + equal(getState().devices.phones.length, 0, + "Defaults to an empty array of phones"); + ok(getState().devices.types.includes("phones"), + "Device types contain phones"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_add_viewport.js b/devtools/client/responsive.html/test/unit/test_add_viewport.js new file mode 100644 index 000000000..b2fc3613d --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_add_viewport.js @@ -0,0 +1,23 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test adding viewports to the page. + +const { addViewport } = + require("devtools/client/responsive.html/actions/viewports"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + equal(getState().viewports.length, 0, "Defaults to no viewpots at startup"); + + dispatch(addViewport()); + equal(getState().viewports.length, 1, "One viewport total"); + + // For the moment, there can be at most one viewport. + dispatch(addViewport()); + equal(getState().viewports.length, 1, "One viewport total, again"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_change_device.js b/devtools/client/responsive.html/test/unit/test_change_device.js new file mode 100644 index 000000000..0e7a6c87a --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_change_device.js @@ -0,0 +1,42 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test changing the viewport device. + +const { + addDevice, + addDeviceType, +} = require("devtools/client/responsive.html/actions/devices"); +const { + addViewport, + changeDevice, +} = require("devtools/client/responsive.html/actions/viewports"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + dispatch(addDeviceType("phones")); + dispatch(addDevice({ + "name": "Firefox OS Flame", + "width": 320, + "height": 570, + "pixelRatio": 1.5, + "userAgent": "Mozilla/5.0 (Mobile; rv:39.0) Gecko/39.0 Firefox/39.0", + "touch": true, + "firefoxOS": true, + "os": "fxos" + }, "phones")); + dispatch(addViewport()); + + let viewport = getState().viewports[0]; + equal(viewport.device, "", "Default device is unselected"); + + dispatch(changeDevice(0, "Firefox OS Flame")); + + viewport = getState().viewports[0]; + equal(viewport.device, "Firefox OS Flame", + "Changed to Firefox OS Flame device"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_change_display_pixel_ratio.js b/devtools/client/responsive.html/test/unit/test_change_display_pixel_ratio.js new file mode 100644 index 000000000..d8d968c2d --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_change_display_pixel_ratio.js @@ -0,0 +1,22 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test changing the display pixel ratio. + +const { changeDisplayPixelRatio } = + require("devtools/client/responsive.html/actions/display-pixel-ratio"); +const NEW_PIXEL_RATIO = 5.5; + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + equal(getState().displayPixelRatio, 0, + "Defaults to 0 at startup"); + + dispatch(changeDisplayPixelRatio(NEW_PIXEL_RATIO)); + equal(getState().displayPixelRatio, NEW_PIXEL_RATIO, + `Display Pixel Ratio changed to ${NEW_PIXEL_RATIO}`); +}); diff --git a/devtools/client/responsive.html/test/unit/test_change_location.js b/devtools/client/responsive.html/test/unit/test_change_location.js new file mode 100644 index 000000000..d45ce5c7a --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_change_location.js @@ -0,0 +1,22 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test changing the location of the displayed page. + +const { changeLocation } = + require("devtools/client/responsive.html/actions/location"); + +const TEST_URL = "http://example.com"; + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + equal(getState().location, "about:blank", + "Defaults to about:blank at startup"); + + dispatch(changeLocation(TEST_URL)); + equal(getState().location, TEST_URL, "Location changed to TEST_URL"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_change_network_throttling.js b/devtools/client/responsive.html/test/unit/test_change_network_throttling.js new file mode 100644 index 000000000..c20ae8133 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_change_network_throttling.js @@ -0,0 +1,27 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test changing the network throttling state + +const { + changeNetworkThrottling, +} = require("devtools/client/responsive.html/actions/network-throttling"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + ok(!getState().networkThrottling.enabled, + "Network throttling is disabled by default."); + equal(getState().networkThrottling.profile, "", + "Network throttling profile is empty by default."); + + dispatch(changeNetworkThrottling(true, "Bob")); + + ok(getState().networkThrottling.enabled, + "Network throttling is enabled."); + equal(getState().networkThrottling.profile, "Bob", + "Network throttling profile is set."); +}); diff --git a/devtools/client/responsive.html/test/unit/test_change_pixel_ratio.js b/devtools/client/responsive.html/test/unit/test_change_pixel_ratio.js new file mode 100644 index 000000000..b594caef5 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_change_pixel_ratio.js @@ -0,0 +1,22 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test changing the viewport pixel ratio. + +const { addViewport, changePixelRatio } = + require("devtools/client/responsive.html/actions/viewports"); +const NEW_PIXEL_RATIO = 5.5; + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + dispatch(addViewport()); + dispatch(changePixelRatio(0, NEW_PIXEL_RATIO)); + + let viewport = getState().viewports[0]; + equal(viewport.pixelRatio.value, NEW_PIXEL_RATIO, + `Viewport's pixel ratio changed to ${NEW_PIXEL_RATIO}`); +}); diff --git a/devtools/client/responsive.html/test/unit/test_resize_viewport.js b/devtools/client/responsive.html/test/unit/test_resize_viewport.js new file mode 100644 index 000000000..4b85554bf --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_resize_viewport.js @@ -0,0 +1,21 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test resizing the viewport. + +const { addViewport, resizeViewport } = + require("devtools/client/responsive.html/actions/viewports"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + dispatch(addViewport()); + dispatch(resizeViewport(0, 500, 500)); + + let viewport = getState().viewports[0]; + equal(viewport.width, 500, "Resized width of 500"); + equal(viewport.height, 500, "Resized height of 500"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_rotate_viewport.js b/devtools/client/responsive.html/test/unit/test_rotate_viewport.js new file mode 100644 index 000000000..541fadaa7 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_rotate_viewport.js @@ -0,0 +1,25 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test rotating the viewport. + +const { addViewport, rotateViewport } = + require("devtools/client/responsive.html/actions/viewports"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + dispatch(addViewport()); + + let viewport = getState().viewports[0]; + equal(viewport.width, 320, "Default width of 320"); + equal(viewport.height, 480, "Default height of 480"); + + dispatch(rotateViewport(0)); + viewport = getState().viewports[0]; + equal(viewport.width, 480, "Rotated width of 480"); + equal(viewport.height, 320, "Rotated height of 320"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_update_device_displayed.js b/devtools/client/responsive.html/test/unit/test_update_device_displayed.js new file mode 100644 index 000000000..34c59bb2a --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_update_device_displayed.js @@ -0,0 +1,37 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test updating the device `displayed` property + +const { + addDevice, + addDeviceType, + updateDeviceDisplayed, +} = require("devtools/client/responsive.html/actions/devices"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + let device = { + "name": "Firefox OS Flame", + "width": 320, + "height": 570, + "pixelRatio": 1.5, + "userAgent": "Mozilla/5.0 (Mobile; rv:39.0) Gecko/39.0 Firefox/39.0", + "touch": true, + "firefoxOS": true, + "os": "fxos" + }; + + dispatch(addDeviceType("phones")); + dispatch(addDevice(device, "phones")); + dispatch(updateDeviceDisplayed(device, "phones", true)); + + equal(getState().devices.phones.length, 1, + "Correct number of phones"); + ok(getState().devices.phones[0].displayed, + "Device phone list contains enabled Firefox OS Flame"); +}); diff --git a/devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js b/devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js new file mode 100644 index 000000000..f8ba2a4b6 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/test_update_touch_simulation_enabled.js @@ -0,0 +1,23 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test updating the touch simulation `enabled` property + +const { + changeTouchSimulation, +} = require("devtools/client/responsive.html/actions/touch-simulation"); + +add_task(function* () { + let store = Store(); + const { getState, dispatch } = store; + + ok(!getState().touchSimulation.enabled, + "Touch simulation is disabled by default."); + + dispatch(changeTouchSimulation(true)); + + ok(getState().touchSimulation.enabled, + "Touch simulation is enabled."); +}); diff --git a/devtools/client/responsive.html/test/unit/xpcshell.ini b/devtools/client/responsive.html/test/unit/xpcshell.ini new file mode 100644 index 000000000..06b5e4994 --- /dev/null +++ b/devtools/client/responsive.html/test/unit/xpcshell.ini @@ -0,0 +1,18 @@ +[DEFAULT] +tags = devtools +head = head.js ../../../framework/test/shared-redux-head.js +tail = +firefox-appdir = browser + +[test_add_device.js] +[test_add_device_type.js] +[test_add_viewport.js] +[test_change_device.js] +[test_change_display_pixel_ratio.js] +[test_change_location.js] +[test_change_network_throttling.js] +[test_change_pixel_ratio.js] +[test_resize_viewport.js] +[test_rotate_viewport.js] +[test_update_device_displayed.js] +[test_update_touch_simulation_enabled.js] -- cgit v1.2.3