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 --- dom/system/tests/chrome.ini | 4 + dom/system/tests/file_bug1197901.html | 16 ++ dom/system/tests/marionette/manifest.ini | 5 + .../tests/marionette/test_proximity_change.js | 83 ++++++++++ dom/system/tests/marionette/test_proximity_init.js | 70 +++++++++ dom/system/tests/mochitest.ini | 8 + .../tests/preload-SystemUpdateManager-jsm.js | 80 ++++++++++ dom/system/tests/test_bug1197901.html | 96 +++++++++++ dom/system/tests/test_constants.xul | 141 +++++++++++++++++ dom/system/tests/test_system_update_enabled.html | 175 +++++++++++++++++++++ dom/system/tests/worker_constants.js | 82 ++++++++++ 11 files changed, 760 insertions(+) create mode 100644 dom/system/tests/chrome.ini create mode 100644 dom/system/tests/file_bug1197901.html create mode 100644 dom/system/tests/marionette/manifest.ini create mode 100644 dom/system/tests/marionette/test_proximity_change.js create mode 100644 dom/system/tests/marionette/test_proximity_init.js create mode 100644 dom/system/tests/mochitest.ini create mode 100644 dom/system/tests/preload-SystemUpdateManager-jsm.js create mode 100644 dom/system/tests/test_bug1197901.html create mode 100644 dom/system/tests/test_constants.xul create mode 100644 dom/system/tests/test_system_update_enabled.html create mode 100644 dom/system/tests/worker_constants.js (limited to 'dom/system/tests') diff --git a/dom/system/tests/chrome.ini b/dom/system/tests/chrome.ini new file mode 100644 index 000000000..79441b157 --- /dev/null +++ b/dom/system/tests/chrome.ini @@ -0,0 +1,4 @@ +[DEFAULT] +support-files = worker_constants.js + +[test_constants.xul] diff --git a/dom/system/tests/file_bug1197901.html b/dom/system/tests/file_bug1197901.html new file mode 100644 index 000000000..44e63c3c1 --- /dev/null +++ b/dom/system/tests/file_bug1197901.html @@ -0,0 +1,16 @@ +
Sensor events testing
+ diff --git a/dom/system/tests/marionette/manifest.ini b/dom/system/tests/marionette/manifest.ini new file mode 100644 index 000000000..a8458c450 --- /dev/null +++ b/dom/system/tests/marionette/manifest.ini @@ -0,0 +1,5 @@ +[DEFAULT] +run-if = buildapp == 'b2g' + +[test_proximity_init.js] +[test_proximity_change.js] diff --git a/dom/system/tests/marionette/test_proximity_change.js b/dom/system/tests/marionette/test_proximity_change.js new file mode 100644 index 000000000..a4c54f12b --- /dev/null +++ b/dom/system/tests/marionette/test_proximity_change.js @@ -0,0 +1,83 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 10000; + +var receivedEvent = false; +var expectedEvent; + +function enableProximityListener() { + // Setup device proximity event listener, expect defaults + log("Enabling 'deviceproximity' event listener."); + + // Bug 814043: Device proximity event 'min' and 'max' attributes incorrect + // Until that is fixed, expect 1:0:1 instead of 1:0:0 + // expectedEvent = new DeviceProximityEvent("deviceproximity", + // {value:1, min:0, max:0}); + expectedEvent = new DeviceProximityEvent("deviceproximity", + {value:1, min:0, max:1}); + + window.addEventListener('deviceproximity', listener); + log("Waiting for device proximity event."); + waitFor(changeProximity, function() { + return(receivedEvent); + }); +} + +function listener(event) { + // Received proximity update + log("Received 'deviceproximity' event via listener (value:" + + event.value + " min:" + event.min + " max:" + event.max + ")."); + // Verify event values are as expected + is(event.value, expectedEvent.value, "value"); + is(event.min, expectedEvent.min, "min"); + is(event.max, expectedEvent.max, "max"); + receivedEvent = true; +} + +function changeProximity() { + // Change emulator's proximity and verify event attributes + let newValue = "7:3:15"; + + // Bug 814043: Device proximity event 'min' and 'max' attributes won't change + // Until fixed, expect proximity event min to be '0' and max to be '1' always + // expectedEvent = new DeviceProximityEvent("deviceproximity", + // {value: 7, min: 3, max: 15}); + expectedEvent = new DeviceProximityEvent("deviceproximity", + {value:7, min:0, max:1}); + + // Setup handler and verify 'ondeviceproximity' event + window.ondeviceproximity = function(event) { + log("Received 'ondeviceproximity' event via handler (value:" + + event.value + " min:" + event.min + " max:" + + event.max + ")."); + is(event.value, expectedEvent.value, "value"); + is(event.min, expectedEvent.min, "min"); + is(event.max, expectedEvent.max, "max"); + // Turn off event handler and listener + window.ondeviceproximity = null; + window.removeEventListener('deviceproximity', listener); + restoreProximity(); + }; + + log("Sending emulator command to fake proximity change (" + newValue + ")."); + runEmulatorCmd("sensor set proximity " + newValue, function(result) { + log("Emulator callback."); + }); +} + +function restoreProximity() { + // Set the emulator's proximity value back to original + newValue = "1:0:0"; + log("Sending emulator command to restore proximity (" + newValue + ")."); + runEmulatorCmd("sensor set proximity " + newValue, function(result) { + cleanUp(); + }); +} + +function cleanUp() { + finish(); +} + +// Start the test +enableProximityListener(); diff --git a/dom/system/tests/marionette/test_proximity_init.js b/dom/system/tests/marionette/test_proximity_init.js new file mode 100644 index 000000000..1a56e6e46 --- /dev/null +++ b/dom/system/tests/marionette/test_proximity_init.js @@ -0,0 +1,70 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 10000; + +function testEventInit() { + let initValue = 7; + let initMin = 1; + let initMax = 30; + + // Test DeviceProximityEvent initialization + log("Verifying DeviceProximityEvent constructor."); + let event = new DeviceProximityEvent("deviceproximity", + {value: initValue, min: initMin, max: initMax}); + is(event.type, "deviceproximity", "event type"); + is(event.value, initValue, "value"); + is(event.min, initMin, "min"); + is(event.max, initMax, "max"); + if (event.value !== initValue || + event.min !== initMin || + event.max !== initMax) { + log("DeviceProximityEvent not initialized correctly."); + } + + // Test UserProximityEvent initialization + log("Verifying UserProximityEvent constructor."); + event = new UserProximityEvent("userproximity", {near: true}); + is(event.type, "userproximity", "event type"); + ok(event.near, "Initialization of UserProximityEvent"); + verifyDefaultStatus(); +} + +function verifyDefaultStatus() { + let emulatorDone = false; + + // Ensure that device proximity is enabled by default + log("Getting sensor status from emulator."); + + runEmulatorCmd("sensor status", function(result) { + log("Received sensor status (" + result[4] + ")."); + is(result[4], "proximity: enabled.", "Proximity sensor enabled by default"); + emulatorDone = true; + }); + + // Have this here so test doesn't drop out if emulator callback is slow + waitFor(getDefaultProximity, function() { + return(emulatorDone); + }); +} + +function getDefaultProximity() { + let expected = "1:0:0"; + + // Get and verify the default emulator proximity value + log("Getting device proximity from emulator."); + + runEmulatorCmd("sensor get proximity", function(result) { + let values = result[0].split(" ")[2]; + log("Received emulator proximity (" + values + ")."); + is(values, "1:0:0", "Default proximity values"); + cleanUp(); + }); +} + +function cleanUp() { + finish(); +} + +// Start the test +testEventInit(); diff --git a/dom/system/tests/mochitest.ini b/dom/system/tests/mochitest.ini new file mode 100644 index 000000000..72bdf5cf6 --- /dev/null +++ b/dom/system/tests/mochitest.ini @@ -0,0 +1,8 @@ +[DEFAULT] +support-files = + preload-SystemUpdateManager-jsm.js + file_bug1197901.html + +[test_bug1197901.html] +[test_system_update_enabled.html] +skip-if = true # Tests only ran on B2G diff --git a/dom/system/tests/preload-SystemUpdateManager-jsm.js b/dom/system/tests/preload-SystemUpdateManager-jsm.js new file mode 100644 index 000000000..005b70461 --- /dev/null +++ b/dom/system/tests/preload-SystemUpdateManager-jsm.js @@ -0,0 +1,80 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +'use strict'; + +const {classes: Cc, interfaces: Ci, utils: Cu, manager: Cm} = Components; + +Cu.import('resource://gre/modules/XPCOMUtils.jsm'); + +const cid = '{17a84227-28f4-453d-9b80-9ae75a5682e0}'; +const contractId = '@mozilla.org/test-update-provider;1'; + +function TestUpdateProvider() {} +TestUpdateProvider.prototype = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemUpdateProvider]), + + checkForUpdate: function() { + dump('check for update'); + this._listener.onUpdateAvailable('test-type', 'test-version', 'test-description', Date.now().valueOf(), 5566); + }, + + startDownload: function() { + dump('test start download'); + this._listener.onProgress(10, 100); + }, + + stopDownload: function() { + dump('test stop download'); + }, + + applyUpdate: function() { + dump('apply update'); + }, + + setParameter: function(name, value) { + dump('set parameter'); + return (name === 'dummy' && value === 'dummy-value'); + }, + + getParameter: function(name) { + dump('get parameter'); + if (name === 'dummy') { + return 'dummy-value'; + } + }, + + setListener: function(listener) { + this._listener = listener; + }, + + unsetListener: function() { + this._listener = null; + }, +}; + +var factory = { + createInstance: function(outer, iid) { + if (outer) { + throw Components.results.NS_ERROR_NO_AGGREGATION; + } + + return new TestUpdateProvider().QueryInterface(iid); + }, + lockFactory: function(aLock) { + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + }, + QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]) +}; + +Cm.nsIComponentRegistrar.registerFactory(Components.ID(cid), '', contractId, factory); + +var cm = Cc['@mozilla.org/categorymanager;1'].getService(Ci.nsICategoryManager); +cm.addCategoryEntry('system-update-provider', 'DummyProvider', + contractId + ',' + cid, false, true); + +Cu.import('resource://gre/modules/SystemUpdateService.jsm'); +this.SystemUpdateService.addProvider('{17a84227-28f4-453d-9b80-9ae75a5682e0}', + '@mozilla.org/test-update-provider;1', + 'DummyProvider'); \ No newline at end of file diff --git a/dom/system/tests/test_bug1197901.html b/dom/system/tests/test_bug1197901.html new file mode 100644 index 000000000..938943b66 --- /dev/null +++ b/dom/system/tests/test_bug1197901.html @@ -0,0 +1,96 @@ + + + + + + Test for Bug 1197901 + + + + + +Mozilla Bug +

+ +
+
+ + + + diff --git a/dom/system/tests/test_constants.xul b/dom/system/tests/test_constants.xul new file mode 100644 index 000000000..b4b1c3dc5 --- /dev/null +++ b/dom/system/tests/test_constants.xul @@ -0,0 +1,141 @@ + + + + + + + +

+ +

+  
+  
diff --git a/dom/system/tests/test_system_update_enabled.html b/dom/system/tests/test_system_update_enabled.html new file mode 100644 index 000000000..1d820d37d --- /dev/null +++ b/dom/system/tests/test_system_update_enabled.html @@ -0,0 +1,175 @@ + + + + + + System Update API Test + + + + +Test System Update API + + + + diff --git a/dom/system/tests/worker_constants.js b/dom/system/tests/worker_constants.js new file mode 100644 index 000000000..62d79fe54 --- /dev/null +++ b/dom/system/tests/worker_constants.js @@ -0,0 +1,82 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function log(text) { + dump("WORKER "+text+"\n"); +} + +function send(message) { + self.postMessage(message); +} + +self.onmessage = function(msg) { + self.onmessage = function(msg) { + log("ignored message "+JSON.stringify(msg.data)); + }; + let { isDebugBuild, umask } = msg.data; + try { + test_name(); + test_xul(); + test_debugBuildWorkerThread(isDebugBuild); + test_umaskWorkerThread(umask); + test_bits(); + } catch (x) { + log("Catching error: " + x); + log("Stack: " + x.stack); + log("Source: " + x.toSource()); + ok(false, x.toString() + "\n" + x.stack); + } + finish(); +}; + +function finish() { + send({kind: "finish"}); +} + +function ok(condition, description) { + send({kind: "ok", condition: condition, description:description}); +} +function is(a, b, description) { + send({kind: "is", a: a, b:b, description:description}); +} +function isnot(a, b, description) { + send({kind: "isnot", a: a, b:b, description:description}); +} + +// Test that OS.Constants.Sys.Name is defined +function test_name() { + isnot(null, OS.Constants.Sys.Name, "OS.Constants.Sys.Name is defined"); +} + +// Test that OS.Constants.Sys.DEBUG is set properly in ChromeWorker thread +function test_debugBuildWorkerThread(isDebugBuild) { + is(isDebugBuild, !!OS.Constants.Sys.DEBUG, "OS.Constants.Sys.DEBUG is set properly on worker thread"); +} + +// Test that OS.Constants.Sys.umask is set properly in ChromeWorker thread +function test_umaskWorkerThread(umask) { + is(umask, OS.Constants.Sys.umask, + "OS.Constants.Sys.umask is set properly on worker thread: " + + ("0000"+umask.toString(8)).slice(-4)); +} + +// Test that OS.Constants.Path.libxul lets us open libxul +function test_xul() { + let lib; + isnot(null, OS.Constants.Path.libxul, "libxul is defined"); + try { + lib = ctypes.open(OS.Constants.Path.libxul); + lib.declare("DumpJSStack", ctypes.default_abi, ctypes.void_t); + } catch (x) { + ok(false, "test_xul: Could not open libxul: " + x); + } + if (lib) { + lib.close(); + } + ok(true, "test_xul: opened libxul successfully"); +} + +// Check if the value of OS.Constants.Sys.bits is 32 or 64 +function test_bits(){ + is(OS.Constants.Sys.bits, ctypes.int.ptr.size * 8, "OS.Constants.Sys.bits is either 32 or 64"); +} -- cgit v1.2.3