forked from mirrors/gecko-dev
Bug 1532514 - Update sinon to v7.2.7. r=markh
Differential Revision: https://phabricator.services.mozilla.com/D22046 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b72a1a06b5
commit
d391c790bc
64 changed files with 32011 additions and 12131 deletions
|
|
@ -323,7 +323,7 @@ testing/mochitest/MochiKit/**
|
||||||
testing/mochitest/tests/MochiKit-1.4.2/**
|
testing/mochitest/tests/MochiKit-1.4.2/**
|
||||||
testing/mochitest/tests/SimpleTest/**
|
testing/mochitest/tests/SimpleTest/**
|
||||||
testing/modules/ajv-4.1.1.js
|
testing/modules/ajv-4.1.1.js
|
||||||
testing/modules/sinon-2.3.2.js
|
testing/modules/sinon-7.2.7.js
|
||||||
# octothorpe used for pref file comment causes parsing error
|
# octothorpe used for pref file comment causes parsing error
|
||||||
testing/mozbase/mozprofile/tests/files/prefs_with_comments.js
|
testing/mozbase/mozprofile/tests/files/prefs_with_comments.js
|
||||||
testing/talos/talos/scripts/jszip.min.js
|
testing/talos/talos/scripts/jszip.min.js
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
* correctly prevent default events, and follows the correct code path.
|
* correctly prevent default events, and follows the correct code path.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
|
|
||||||
var gTests = [
|
var gTests = [
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -181,18 +183,11 @@ var gTestWin = null;
|
||||||
// The test currently running.
|
// The test currently running.
|
||||||
var gCurrentTest = null;
|
var gCurrentTest = null;
|
||||||
|
|
||||||
var sandbox;
|
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
waitForExplicitFinish();
|
waitForExplicitFinish();
|
||||||
|
|
||||||
/* global sinon */
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
sandbox = sinon.sandbox.create();
|
|
||||||
|
|
||||||
registerCleanupFunction(function() {
|
registerCleanupFunction(function() {
|
||||||
sandbox.restore();
|
sinon.restore();
|
||||||
delete window.sinon;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gTestWin = openDialog(location, "", "chrome,all,dialog=no", "about:blank");
|
gTestWin = openDialog(location, "", "chrome,all,dialog=no", "about:blank");
|
||||||
|
|
@ -250,7 +245,7 @@ function setupTestBrowserWindow() {
|
||||||
// Replace methods.
|
// Replace methods.
|
||||||
gReplacedMethods.forEach(function(methodName) {
|
gReplacedMethods.forEach(function(methodName) {
|
||||||
let targetObj = methodName == "getShortcutOrURIAndPostData" ? UrlbarUtils : gTestWin;
|
let targetObj = methodName == "getShortcutOrURIAndPostData" ? UrlbarUtils : gTestWin;
|
||||||
sandbox.stub(targetObj, methodName).returnsArg(0);
|
sinon.stub(targetObj, methodName).returnsArg(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Inject links in content.
|
// Inject links in content.
|
||||||
|
|
@ -286,7 +281,7 @@ function runNextTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to next target.
|
// Move to next target.
|
||||||
sandbox.resetHistory();
|
sinon.resetHistory();
|
||||||
let target = gCurrentTest.targets.shift();
|
let target = gCurrentTest.targets.shift();
|
||||||
|
|
||||||
info(gCurrentTest.desc + ": testing " + target);
|
info(gCurrentTest.desc + ": testing " + target);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* global sinon, UIState */
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
/* global UIState */
|
||||||
|
|
||||||
registerCleanupFunction(function() {
|
|
||||||
delete window.sinon;
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastModifiedFixture = 1507655615.87; // Approx Oct 10th 2017
|
const lastModifiedFixture = 1507655615.87; // Approx Oct 10th 2017
|
||||||
const mockTargets = [
|
const mockTargets = [
|
||||||
|
|
@ -255,7 +251,7 @@ add_task(async function sendToDevice_syncNotReady_other_states() {
|
||||||
// Open a tab that's sendable.
|
// Open a tab that's sendable.
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
||||||
await promiseSyncReady();
|
await promiseSyncReady();
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
sandbox.stub(gSync, "syncReady").get(() => false);
|
sandbox.stub(gSync, "syncReady").get(() => false);
|
||||||
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_NOT_VERIFIED });
|
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_NOT_VERIFIED });
|
||||||
sandbox.stub(gSync, "isSendableURI").returns(true);
|
sandbox.stub(gSync, "isSendableURI").returns(true);
|
||||||
|
|
@ -311,7 +307,7 @@ add_task(async function sendToDevice_syncNotReady_configured() {
|
||||||
// Open a tab that's sendable.
|
// Open a tab that's sendable.
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
||||||
await promiseSyncReady();
|
await promiseSyncReady();
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
const syncReady = sandbox.stub(gSync, "syncReady").get(() => false);
|
const syncReady = sandbox.stub(gSync, "syncReady").get(() => false);
|
||||||
const hasSyncedThisSession = sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => false);
|
const hasSyncedThisSession = sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => false);
|
||||||
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
||||||
|
|
@ -455,7 +451,7 @@ add_task(async function sendToDevice_noDevices() {
|
||||||
// Open a tab that's sendable.
|
// Open a tab that's sendable.
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
||||||
await promiseSyncReady();
|
await promiseSyncReady();
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
sandbox.stub(gSync, "syncReady").get(() => true);
|
sandbox.stub(gSync, "syncReady").get(() => true);
|
||||||
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
||||||
sandbox.stub(Weave.Service.clientsEngine, "fxaDevices").get(() => []);
|
sandbox.stub(Weave.Service.clientsEngine, "fxaDevices").get(() => []);
|
||||||
|
|
@ -521,7 +517,7 @@ add_task(async function sendToDevice_devices() {
|
||||||
// Open a tab that's sendable.
|
// Open a tab that's sendable.
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
||||||
await promiseSyncReady();
|
await promiseSyncReady();
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
sandbox.stub(gSync, "syncReady").get(() => true);
|
sandbox.stub(gSync, "syncReady").get(() => true);
|
||||||
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
||||||
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
||||||
|
|
@ -587,7 +583,7 @@ add_task(async function sendToDevice_title() {
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/a", async otherBrowser => {
|
await BrowserTestUtils.withNewTab("http://example.com/a", async otherBrowser => {
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/b", async () => {
|
await BrowserTestUtils.withNewTab("http://example.com/b", async () => {
|
||||||
await promiseSyncReady();
|
await promiseSyncReady();
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
sandbox.stub(gSync, "syncReady").get(() => true);
|
sandbox.stub(gSync, "syncReady").get(() => true);
|
||||||
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
||||||
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
||||||
|
|
@ -644,7 +640,7 @@ add_task(async function sendToDevice_inUrlbar() {
|
||||||
// Open a tab that's sendable.
|
// Open a tab that's sendable.
|
||||||
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
await BrowserTestUtils.withNewTab("http://example.com/", async () => {
|
||||||
await promiseSyncReady();
|
await promiseSyncReady();
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
sandbox.stub(gSync, "syncReady").get(() => true);
|
sandbox.stub(gSync, "syncReady").get(() => true);
|
||||||
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
sandbox.stub(Weave.Service.clientsEngine, "hasSyncedThisSession").get(() => true);
|
||||||
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
sandbox.stub(UIState, "get").returns({ status: UIState.STATUS_SIGNED_IN });
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* global sinon */
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
const URL = "http://example.org/";
|
const URL = "http://example.org/";
|
||||||
|
|
||||||
|
|
@ -38,7 +37,6 @@ let stub = sinon.stub(BrowserPageActions.shareURL, "_sharingService").get(() =>
|
||||||
|
|
||||||
registerCleanupFunction(async function() {
|
registerCleanupFunction(async function() {
|
||||||
stub.restore();
|
stub.restore();
|
||||||
delete window.sinon;
|
|
||||||
await EventUtils.synthesizeNativeMouseMove(document.documentElement, 0, 0);
|
await EventUtils.synthesizeNativeMouseMove(document.documentElement, 0, 0);
|
||||||
await PlacesUtils.history.clear();
|
await PlacesUtils.history.clear();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* global sinon */
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
const TEST_URL = getRootDirectory(gTestPath) + "browser_page_action_menu_share_win.html";
|
const TEST_URL = getRootDirectory(gTestPath) + "browser_page_action_menu_share_win.html";
|
||||||
|
|
||||||
|
|
@ -22,7 +21,6 @@ let stub = sinon.stub(BrowserPageActions.shareURL, "_windowsUIUtils").get(() =>
|
||||||
|
|
||||||
registerCleanupFunction(async function() {
|
registerCleanupFunction(async function() {
|
||||||
stub.restore();
|
stub.restore();
|
||||||
delete window.sinon;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function shareURL() {
|
add_task(async function shareURL() {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,5 @@
|
||||||
/* global sinon */
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
ChromeUtils.import("resource://services-sync/UIState.jsm", this);
|
ChromeUtils.import("resource://services-sync/UIState.jsm", this);
|
||||||
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
registerCleanupFunction(function() {
|
|
||||||
delete window.sinon;
|
|
||||||
});
|
|
||||||
|
|
||||||
function promiseSyncReady() {
|
function promiseSyncReady() {
|
||||||
let service = Cc["@mozilla.org/weave/service;1"]
|
let service = Cc["@mozilla.org/weave/service;1"]
|
||||||
|
|
@ -16,7 +10,7 @@ function promiseSyncReady() {
|
||||||
|
|
||||||
function setupSendTabMocks({ syncReady = true, fxaDevices = null,
|
function setupSendTabMocks({ syncReady = true, fxaDevices = null,
|
||||||
state = UIState.STATUS_SIGNED_IN, isSendableURI = true }) {
|
state = UIState.STATUS_SIGNED_IN, isSendableURI = true }) {
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
sandbox.stub(gSync, "syncReady").get(() => syncReady);
|
sandbox.stub(gSync, "syncReady").get(() => syncReady);
|
||||||
if (fxaDevices) {
|
if (fxaDevices) {
|
||||||
// Clone fxaDevices because it gets sorted in-place.
|
// Clone fxaDevices because it gets sorted in-place.
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||||
/* vim: set sts=2 sw=2 et tw=80: */
|
/* vim: set sts=2 sw=2 et tw=80: */
|
||||||
/* global sinon */
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
|
|
||||||
registerCleanupFunction(() => {
|
|
||||||
delete window.sinon;
|
|
||||||
});
|
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "ExtensionSettingsStore",
|
ChromeUtils.defineModuleGetter(this, "ExtensionSettingsStore",
|
||||||
"resource://gre/modules/ExtensionSettingsStore.jsm");
|
"resource://gre/modules/ExtensionSettingsStore.jsm");
|
||||||
|
|
@ -127,7 +122,7 @@ add_task(async function testExtensionControlledPopup() {
|
||||||
|
|
||||||
// Ensure the panel isn't open.
|
// Ensure the panel isn't open.
|
||||||
ok(onObserverAdded.called, "Observing the event");
|
ok(onObserverAdded.called, "Observing the event");
|
||||||
onObserverAdded.reset();
|
onObserverAdded.resetHistory();
|
||||||
ok(!onObserverRemoved.called, "Observing the event");
|
ok(!onObserverRemoved.called, "Observing the event");
|
||||||
ok(!beforeDisableAddon.called, "Settings have not been restored");
|
ok(!beforeDisableAddon.called, "Settings have not been restored");
|
||||||
ok(panel.getAttribute("panelopen") != "true", "The panel is closed");
|
ok(panel.getAttribute("panelopen") != "true", "The panel is closed");
|
||||||
|
|
@ -140,7 +135,7 @@ add_task(async function testExtensionControlledPopup() {
|
||||||
|
|
||||||
ok(!onObserverAdded.called, "Only one observer has been registered");
|
ok(!onObserverAdded.called, "Only one observer has been registered");
|
||||||
ok(onObserverRemoved.called, "The observer was removed");
|
ok(onObserverRemoved.called, "The observer was removed");
|
||||||
onObserverRemoved.reset();
|
onObserverRemoved.resetHistory();
|
||||||
ok(!beforeDisableAddon.called, "Settings have not been restored");
|
ok(!beforeDisableAddon.called, "Settings have not been restored");
|
||||||
is(panel.getAttribute("panelopen"), "true", "The panel is open");
|
is(panel.getAttribute("panelopen"), "true", "The panel is open");
|
||||||
is(popupnotification.hidden, false, "The popup content is visible");
|
is(popupnotification.hidden, false, "The popup content is visible");
|
||||||
|
|
@ -167,7 +162,7 @@ add_task(async function testExtensionControlledPopup() {
|
||||||
// Force add the observer again to keep changes.
|
// Force add the observer again to keep changes.
|
||||||
await popup.addObserver(id);
|
await popup.addObserver(id);
|
||||||
ok(onObserverAdded.called, "The observer was added again");
|
ok(onObserverAdded.called, "The observer was added again");
|
||||||
onObserverAdded.reset();
|
onObserverAdded.resetHistory();
|
||||||
ok(!onObserverRemoved.called, "The observer is still registered");
|
ok(!onObserverRemoved.called, "The observer is still registered");
|
||||||
is(await popup.userHasConfirmed(id), false, "The user has not confirmed");
|
is(await popup.userHasConfirmed(id), false, "The user has not confirmed");
|
||||||
|
|
||||||
|
|
@ -180,7 +175,7 @@ add_task(async function testExtensionControlledPopup() {
|
||||||
// The observer is removed, but the notification is saved.
|
// The observer is removed, but the notification is saved.
|
||||||
ok(!onObserverAdded.called, "The observer wasn't added");
|
ok(!onObserverAdded.called, "The observer wasn't added");
|
||||||
ok(onObserverRemoved.called, "The observer was removed");
|
ok(onObserverRemoved.called, "The observer was removed");
|
||||||
onObserverRemoved.reset();
|
onObserverRemoved.resetHistory();
|
||||||
is(await popup.userHasConfirmed(id), true, "The user has confirmed");
|
is(await popup.userHasConfirmed(id), true, "The user has confirmed");
|
||||||
is(addon.userDisabled, false, "The extension is still enabled");
|
is(addon.userDisabled, false, "The extension is still enabled");
|
||||||
|
|
||||||
|
|
@ -198,7 +193,7 @@ add_task(async function testExtensionControlledPopup() {
|
||||||
// Force add the observer again to restore changes.
|
// Force add the observer again to restore changes.
|
||||||
await popup.addObserver(id);
|
await popup.addObserver(id);
|
||||||
ok(onObserverAdded.called, "The observer was added a third time");
|
ok(onObserverAdded.called, "The observer was added a third time");
|
||||||
onObserverAdded.reset();
|
onObserverAdded.resetHistory();
|
||||||
ok(!onObserverRemoved.called, "The observer is still active");
|
ok(!onObserverRemoved.called, "The observer is still active");
|
||||||
ok(!beforeDisableAddon.called, "We haven't disabled the add-on yet");
|
ok(!beforeDisableAddon.called, "We haven't disabled the add-on yet");
|
||||||
is(await popup.userHasConfirmed(id), false, "The user has not confirmed");
|
is(await popup.userHasConfirmed(id), false, "The user has not confirmed");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||||
/* vim: set sts=2 sw=2 et tw=80: */
|
/* vim: set sts=2 sw=2 et tw=80: */
|
||||||
/* global sinon */
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ support-files =
|
||||||
!/browser/extensions/formautofill/content/editCreditCard.xhtml
|
!/browser/extensions/formautofill/content/editCreditCard.xhtml
|
||||||
../../../../../browser/extensions/formautofill/content/autofillEditForms.js
|
../../../../../browser/extensions/formautofill/content/autofillEditForms.js
|
||||||
../../../../../browser/extensions/formautofill/skin/shared/editDialog-shared.css
|
../../../../../browser/extensions/formautofill/skin/shared/editDialog-shared.css
|
||||||
../../../../../testing/modules/sinon-2.3.2.js
|
../../../../../testing/modules/sinon-7.2.7.js
|
||||||
# paymentRequest.xhtml is needed for `importDialogDependencies` so that the relative paths of
|
# paymentRequest.xhtml is needed for `importDialogDependencies` so that the relative paths of
|
||||||
# formautofill/edit*.xhtml work from the *-form elements in paymentRequest.xhtml.
|
# formautofill/edit*.xhtml work from the *-form elements in paymentRequest.xhtml.
|
||||||
../../res/paymentRequest.xhtml
|
../../res/paymentRequest.xhtml
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ Test the PaymentStateSubscriberMixin
|
||||||
<title>Test the PaymentStateSubscriberMixin</title>
|
<title>Test the PaymentStateSubscriberMixin</title>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||||
<script src="sinon-2.3.2.js"></script>
|
<script src="sinon-7.2.7.js"></script>
|
||||||
<script src="payments_common.js"></script>
|
<script src="payments_common.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ Test the PaymentsStore
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||||
|
|
||||||
<script src="sinon-2.3.2.js"></script>
|
<script src="sinon-7.2.7.js"></script>
|
||||||
<script src="payments_common.js"></script>
|
<script src="payments_common.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Test the accepted-cards element
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||||
<script src="sinon-2.3.2.js"></script>
|
<script src="sinon-7.2.7.js"></script>
|
||||||
<script src="payments_common.js"></script>
|
<script src="payments_common.js"></script>
|
||||||
<script src="../../res/unprivileged-fallbacks.js"></script>
|
<script src="../../res/unprivileged-fallbacks.js"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Test the address-form element
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||||
<script src="sinon-2.3.2.js"></script>
|
<script src="sinon-7.2.7.js"></script>
|
||||||
<script src="payments_common.js"></script>
|
<script src="payments_common.js"></script>
|
||||||
<script src="../../res/unprivileged-fallbacks.js"></script>
|
<script src="../../res/unprivileged-fallbacks.js"></script>
|
||||||
<script src="autofillEditForms.js"></script>
|
<script src="autofillEditForms.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Test the basic-card-form element
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||||
<script src="sinon-2.3.2.js"></script>
|
<script src="sinon-7.2.7.js"></script>
|
||||||
<script src="payments_common.js"></script>
|
<script src="payments_common.js"></script>
|
||||||
<script src="../../res/unprivileged-fallbacks.js"></script>
|
<script src="../../res/unprivileged-fallbacks.js"></script>
|
||||||
<script src="autofillEditForms.js"></script>
|
<script src="autofillEditForms.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Test the payment-dialog custom element
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
||||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||||
<script src="sinon-2.3.2.js"></script>
|
<script src="sinon-7.2.7.js"></script>
|
||||||
<script src="payments_common.js"></script>
|
<script src="payments_common.js"></script>
|
||||||
<script src="../../res/unprivileged-fallbacks.js"></script>
|
<script src="../../res/unprivileged-fallbacks.js"></script>
|
||||||
<script src="autofillEditForms.js"></script>
|
<script src="autofillEditForms.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,2 @@
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
var {
|
|
||||||
clearInterval,
|
|
||||||
clearTimeout,
|
|
||||||
setInterval,
|
|
||||||
setIntervalWithTarget,
|
|
||||||
setTimeout,
|
|
||||||
setTimeoutWithTarget,
|
|
||||||
} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* global sinon */
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
registerCleanupFunction(async function() {
|
registerCleanupFunction(async function() {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
delete window.sinon;
|
|
||||||
await PlacesUtils.bookmarks.eraseEverything();
|
await PlacesUtils.bookmarks.eraseEverything();
|
||||||
await PlacesUtils.history.clear();
|
await PlacesUtils.history.clear();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* global sinon */
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
const TAG_NAME = "testTag";
|
const TAG_NAME = "testTag";
|
||||||
|
|
||||||
var bookmarks;
|
var bookmarks;
|
||||||
|
|
@ -16,7 +15,6 @@ var bookmarkId;
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
registerCleanupFunction(async function() {
|
registerCleanupFunction(async function() {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
delete window.sinon;
|
|
||||||
await PlacesUtils.bookmarks.eraseEverything();
|
await PlacesUtils.bookmarks.eraseEverything();
|
||||||
await PlacesUtils.history.clear();
|
await PlacesUtils.history.clear();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
// ================================================
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
const {setTimeout, clearTimeout, setInterval, clearInterval} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
||||||
/* eslint-disable mozilla/use-chromeutils-generateqi */
|
/* eslint-disable mozilla/use-chromeutils-generateqi */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
/* global sinon */
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -8,10 +7,7 @@ const {UIState} = ChromeUtils.import("resource://services-sync/UIState.jsm", {})
|
||||||
const {FxAccountsPairingFlow} = ChromeUtils.import("resource://gre/modules/FxAccountsPairing.jsm", {});
|
const {FxAccountsPairingFlow} = ChromeUtils.import("resource://gre/modules/FxAccountsPairing.jsm", {});
|
||||||
|
|
||||||
// Use sinon for mocking.
|
// Use sinon for mocking.
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
registerCleanupFunction(() => {
|
|
||||||
delete window.sinon; // test fails with this reference left behind.
|
|
||||||
});
|
|
||||||
|
|
||||||
let flowCounter = 0;
|
let flowCounter = 0;
|
||||||
|
|
||||||
|
|
@ -37,7 +33,7 @@ add_task(async function setup() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testShowsQRCode() {
|
add_task(async function testShowsQRCode() {
|
||||||
await runWithPairingDialog(async (win, sinon) => {
|
await runWithPairingDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let qrContainer = doc.getElementById("qrContainer");
|
let qrContainer = doc.getElementById("qrContainer");
|
||||||
let qrWrapper = doc.getElementById("qrWrapper");
|
let qrWrapper = doc.getElementById("qrWrapper");
|
||||||
|
|
@ -59,7 +55,7 @@ add_task(async function testShowsQRCode() {
|
||||||
add_task(async function testCantShowQrCode() {
|
add_task(async function testCantShowQrCode() {
|
||||||
const origStart = FxAccountsPairingFlow.start;
|
const origStart = FxAccountsPairingFlow.start;
|
||||||
FxAccountsPairingFlow.start = async () => { throw new Error("boom"); };
|
FxAccountsPairingFlow.start = async () => { throw new Error("boom"); };
|
||||||
await runWithPairingDialog(async (win, sinon) => {
|
await runWithPairingDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let qrWrapper = doc.getElementById("qrWrapper");
|
let qrWrapper = doc.getElementById("qrWrapper");
|
||||||
|
|
||||||
|
|
@ -76,7 +72,7 @@ add_task(async function testCantShowQrCode() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testSwitchToWebContent() {
|
add_task(async function testSwitchToWebContent() {
|
||||||
await runWithPairingDialog(async (win, sinon) => {
|
await runWithPairingDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let qrWrapper = doc.getElementById("qrWrapper");
|
let qrWrapper = doc.getElementById("qrWrapper");
|
||||||
|
|
||||||
|
|
@ -91,7 +87,7 @@ add_task(async function testSwitchToWebContent() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testError() {
|
add_task(async function testError() {
|
||||||
await runWithPairingDialog(async (win, sinon) => {
|
await runWithPairingDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let qrWrapper = doc.getElementById("qrWrapper");
|
let qrWrapper = doc.getElementById("qrWrapper");
|
||||||
|
|
||||||
|
|
@ -120,11 +116,9 @@ async function runWithPairingDialog(test) {
|
||||||
|
|
||||||
let win = await promiseSubDialogLoaded;
|
let win = await promiseSubDialogLoaded;
|
||||||
|
|
||||||
let ss = sinon.sandbox.create();
|
await test(win);
|
||||||
|
|
||||||
await test(win, ss);
|
sinon.restore();
|
||||||
|
|
||||||
ss.restore();
|
|
||||||
|
|
||||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
/* global sinon */
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
@ -14,11 +13,7 @@ var fxAccountsCommon = {};
|
||||||
ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", fxAccountsCommon);
|
ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", fxAccountsCommon);
|
||||||
|
|
||||||
// Use sinon for mocking.
|
// Use sinon for mocking.
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
registerCleanupFunction(() => {
|
|
||||||
delete window.sinon; // test fails with this reference left behind.
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
// Sync start-up will interfere with our tests, don't let UIState send UI updates.
|
// Sync start-up will interfere with our tests, don't let UIState send UI updates.
|
||||||
|
|
@ -42,7 +37,7 @@ add_task(async function setup() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testDisconnectUI() {
|
add_task(async function testDisconnectUI() {
|
||||||
await runTestWithSanitizeDialog(async (win, sinon) => {
|
await runTestWithSanitizeDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let butDisconnect = doc.getElementById("butDisconnect");
|
let butDisconnect = doc.getElementById("butDisconnect");
|
||||||
let butDeleteSync = doc.getElementById("deleteRemoteSyncData");
|
let butDeleteSync = doc.getElementById("deleteRemoteSyncData");
|
||||||
|
|
@ -92,7 +87,7 @@ add_task(async function testDisconnectUI() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testDisconnectNoSanitize() {
|
add_task(async function testDisconnectNoSanitize() {
|
||||||
await runTestWithSanitizeDialog(async (win, sinon) => {
|
await runTestWithSanitizeDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let butDisconnect = doc.getElementById("butDisconnect");
|
let butDisconnect = doc.getElementById("butDisconnect");
|
||||||
|
|
||||||
|
|
@ -130,7 +125,7 @@ add_task(async function testDisconnectNoSanitize() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testSanitizeSync() {
|
add_task(async function testSanitizeSync() {
|
||||||
await runTestWithSanitizeDialog(async (win, sinon) => {
|
await runTestWithSanitizeDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
let butDisconnect = doc.getElementById("butDisconnect");
|
let butDisconnect = doc.getElementById("butDisconnect");
|
||||||
let butDeleteSync = doc.getElementById("deleteRemoteSyncData");
|
let butDeleteSync = doc.getElementById("deleteRemoteSyncData");
|
||||||
|
|
@ -196,7 +191,7 @@ add_task(async function testSanitizeSync() {
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function testSanitizeBrowser() {
|
add_task(async function testSanitizeBrowser() {
|
||||||
await runTestWithSanitizeDialog(async (win, sinon) => {
|
await runTestWithSanitizeDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
|
|
||||||
// The dialog should have the main UI visible.
|
// The dialog should have the main UI visible.
|
||||||
|
|
@ -232,7 +227,7 @@ add_task(async function testDisconnectAlreadyRunning() {
|
||||||
SyncDisconnectInternal.promiseDisconnectFinished =
|
SyncDisconnectInternal.promiseDisconnectFinished =
|
||||||
new Promise(resolve => resolveExisting = resolve);
|
new Promise(resolve => resolveExisting = resolve);
|
||||||
|
|
||||||
await runTestWithSanitizeDialog(async (win, sinon) => {
|
await runTestWithSanitizeDialog(async (win) => {
|
||||||
let doc = win.document;
|
let doc = win.document;
|
||||||
// The dialog should have "waiting" visible.
|
// The dialog should have "waiting" visible.
|
||||||
Assert.equal(doc.getElementById("deleteOptionsContent").hidden, true);
|
Assert.equal(doc.getElementById("deleteOptionsContent").hidden, true);
|
||||||
|
|
@ -261,11 +256,9 @@ async function runTestWithSanitizeDialog(test) {
|
||||||
|
|
||||||
let win = await promiseSubDialogLoaded;
|
let win = await promiseSubDialogLoaded;
|
||||||
|
|
||||||
let ss = sinon.sandbox.create();
|
await test(win);
|
||||||
|
|
||||||
await test(win, ss);
|
sinon.restore();
|
||||||
|
|
||||||
ss.restore();
|
|
||||||
|
|
||||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,16 +62,25 @@ const FIXTURE = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let originalSyncedTabsInternal = null;
|
|
||||||
|
|
||||||
const {SyncedTabs} = ChromeUtils.import("resource://services-sync/SyncedTabs.jsm");
|
const {SyncedTabs} = ChromeUtils.import("resource://services-sync/SyncedTabs.jsm");
|
||||||
|
|
||||||
async function testClean() {
|
function setupSyncedTabsStubs({
|
||||||
let syncedTabsDeckComponent = window.SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
|
signedInUser = {verified: true},
|
||||||
syncedTabsDeckComponent._getSignedInUser.restore();
|
loginFailed = false,
|
||||||
SyncedTabs._internal.getTabClients.restore();
|
isConfiguredToSyncTabs = true,
|
||||||
SyncedTabs._internal = originalSyncedTabsInternal;
|
hasSyncedThisSession = true,
|
||||||
|
tabClients = Cu.cloneInto(FIXTURE, {}),
|
||||||
|
} = {}) {
|
||||||
|
sinon.stub(SidebarUI.browser.contentWindow.syncedTabsDeckComponent, "_getSignedInUser").resolves(signedInUser);
|
||||||
|
sinon.stub(SyncedTabs._internal, "getTabClients").resolves(tabClients);
|
||||||
|
sinon.stub(SyncedTabs._internal, "syncTabs").resolves();
|
||||||
|
sinon.stub(SyncedTabs._internal, "loginFailed").value(loginFailed);
|
||||||
|
sinon.stub(SyncedTabs._internal, "isConfiguredToSyncTabs").value(isConfiguredToSyncTabs);
|
||||||
|
sinon.stub(SyncedTabs._internal, "hasSyncedThisSession").value(hasSyncedThisSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testClean() {
|
||||||
|
sinon.restore();
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
window.SidebarUI.browser.contentWindow.addEventListener("unload", function() {
|
window.SidebarUI.browser.contentWindow.addEventListener("unload", function() {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
@ -89,16 +98,7 @@ add_task(async function testSyncedTabsSidebarList() {
|
||||||
|
|
||||||
Assert.ok(syncedTabsDeckComponent, "component exists");
|
Assert.ok(syncedTabsDeckComponent, "component exists");
|
||||||
|
|
||||||
originalSyncedTabsInternal = SyncedTabs._internal;
|
setupSyncedTabsStubs();
|
||||||
SyncedTabs._internal = {
|
|
||||||
isConfiguredToSyncTabs: true,
|
|
||||||
hasSyncedThisSession: true,
|
|
||||||
getTabClients() { return Promise.resolve([]); },
|
|
||||||
syncTabs() { return Promise.resolve(); },
|
|
||||||
};
|
|
||||||
|
|
||||||
sinon.stub(syncedTabsDeckComponent, "_getSignedInUser", () => Promise.resolve({verified: true}));
|
|
||||||
sinon.stub(SyncedTabs._internal, "getTabClients", () => Promise.resolve(Cu.cloneInto(FIXTURE, {})));
|
|
||||||
|
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
// This is a hacky way of waiting for the view to render. The view renders
|
// This is a hacky way of waiting for the view to render. The view renders
|
||||||
|
|
@ -140,27 +140,17 @@ add_task(async function testSyncedTabsSidebarFilteredList() {
|
||||||
|
|
||||||
Assert.ok(syncedTabsDeckComponent, "component exists");
|
Assert.ok(syncedTabsDeckComponent, "component exists");
|
||||||
|
|
||||||
originalSyncedTabsInternal = SyncedTabs._internal;
|
setupSyncedTabsStubs();
|
||||||
SyncedTabs._internal = {
|
|
||||||
isConfiguredToSyncTabs: true,
|
|
||||||
hasSyncedThisSession: true,
|
|
||||||
getTabClients() { return Promise.resolve([]); },
|
|
||||||
syncTabs() { return Promise.resolve(); },
|
|
||||||
};
|
|
||||||
|
|
||||||
sinon.stub(syncedTabsDeckComponent, "_getSignedInUser", () => Promise.resolve({verified: true}));
|
|
||||||
sinon.stub(SyncedTabs._internal, "getTabClients", () => Promise.resolve(Cu.cloneInto(FIXTURE, {})));
|
|
||||||
|
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
// This is a hacky way of waiting for the view to render. The view renders
|
|
||||||
// after the following promise (a different instance of which is triggered
|
|
||||||
// in updatePanel) resolves, so we wait for it here as well
|
|
||||||
await syncedTabsDeckComponent.tabListComponent._store.getData();
|
|
||||||
|
|
||||||
let filterInput = syncedTabsDeckComponent._window.document.querySelector(".tabsFilter");
|
let filterInput = syncedTabsDeckComponent._window.document.querySelector(".tabsFilter");
|
||||||
filterInput.value = "filter text";
|
filterInput.value = "filter text";
|
||||||
filterInput.blur();
|
filterInput.blur();
|
||||||
|
|
||||||
|
// This is a hacky way of waiting for the view to render. The view renders
|
||||||
|
// after the following promise (a different instance of which is triggered
|
||||||
|
// in updatePanel) resolves, so we wait for it here as well
|
||||||
await syncedTabsDeckComponent.tabListComponent._store.getData("filter text");
|
await syncedTabsDeckComponent.tabListComponent._store.getData("filter text");
|
||||||
|
|
||||||
let selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
let selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
|
|
@ -193,74 +183,110 @@ add_task(async function testSyncedTabsSidebarFilteredList() {
|
||||||
add_task(testClean);
|
add_task(testClean);
|
||||||
|
|
||||||
add_task(async function testSyncedTabsSidebarStatus() {
|
add_task(async function testSyncedTabsSidebarStatus() {
|
||||||
let account = null;
|
|
||||||
|
|
||||||
await SidebarUI.show("viewTabsSidebar");
|
await SidebarUI.show("viewTabsSidebar");
|
||||||
let syncedTabsDeckComponent = window.SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
|
let syncedTabsDeckComponent = window.SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
|
||||||
|
|
||||||
originalSyncedTabsInternal = SyncedTabs._internal;
|
Assert.ok(syncedTabsDeckComponent, "component exists");
|
||||||
SyncedTabs._internal = {
|
|
||||||
|
setupSyncedTabsStubs({
|
||||||
|
signedInUser: Promise.reject("Test error"),
|
||||||
loginFailed: false,
|
loginFailed: false,
|
||||||
isConfiguredToSyncTabs: false,
|
isConfiguredToSyncTabs: false,
|
||||||
hasSyncedThisSession: false,
|
hasSyncedThisSession: false,
|
||||||
getTabClients() {},
|
tabClients: [],
|
||||||
syncTabs() { return Promise.resolve(); },
|
});
|
||||||
};
|
|
||||||
|
|
||||||
Assert.ok(syncedTabsDeckComponent, "component exists");
|
|
||||||
|
|
||||||
sinon.spy(syncedTabsDeckComponent, "updatePanel");
|
|
||||||
sinon.spy(syncedTabsDeckComponent, "observe");
|
|
||||||
|
|
||||||
sinon.stub(syncedTabsDeckComponent, "_getSignedInUser", () => Promise.reject("Test error"));
|
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
|
|
||||||
let selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
let selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("notAuthedInfo"),
|
Assert.ok(selectedPanel.classList.contains("notAuthedInfo"),
|
||||||
"not-authed panel is selected on auth error");
|
"not-authed panel is selected on auth error");
|
||||||
|
sinon.restore();
|
||||||
|
|
||||||
syncedTabsDeckComponent._getSignedInUser.restore();
|
setupSyncedTabsStubs({
|
||||||
sinon.stub(syncedTabsDeckComponent, "_getSignedInUser", () => Promise.resolve(account));
|
signedInUser: null,
|
||||||
|
loginFailed: false,
|
||||||
|
isConfiguredToSyncTabs: false,
|
||||||
|
hasSyncedThisSession: false,
|
||||||
|
tabClients: [],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("notAuthedInfo"),
|
Assert.ok(selectedPanel.classList.contains("notAuthedInfo"),
|
||||||
"not-authed panel is selected");
|
"not-authed panel is selected");
|
||||||
|
sinon.restore();
|
||||||
|
|
||||||
account = {verified: false};
|
setupSyncedTabsStubs({
|
||||||
|
signedInUser: {verified: false},
|
||||||
|
loginFailed: false,
|
||||||
|
isConfiguredToSyncTabs: false,
|
||||||
|
hasSyncedThisSession: false,
|
||||||
|
tabClients: [],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("unverified"),
|
Assert.ok(selectedPanel.classList.contains("unverified"),
|
||||||
"unverified panel is selected");
|
"unverified panel is selected");
|
||||||
|
sinon.restore();
|
||||||
|
|
||||||
SyncedTabs._internal.loginFailed = true;
|
setupSyncedTabsStubs({
|
||||||
account = {verified: true};
|
signedInUser: {verified: true},
|
||||||
|
loginFailed: true,
|
||||||
|
isConfiguredToSyncTabs: false,
|
||||||
|
hasSyncedThisSession: false,
|
||||||
|
tabClients: [],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("reauth"),
|
Assert.ok(selectedPanel.classList.contains("reauth"),
|
||||||
"reauth panel is selected");
|
"reauth panel is selected");
|
||||||
SyncedTabs._internal.loginFailed = false;
|
sinon.restore();
|
||||||
|
|
||||||
account = {verified: true};
|
setupSyncedTabsStubs({
|
||||||
|
signedInUser: {verified: true},
|
||||||
|
loginFailed: false,
|
||||||
|
isConfiguredToSyncTabs: false,
|
||||||
|
hasSyncedThisSession: false,
|
||||||
|
tabClients: [],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("tabs-disabled"),
|
Assert.ok(selectedPanel.classList.contains("tabs-disabled"),
|
||||||
"tabs disabled panel is selected");
|
"tabs disabled panel is selected");
|
||||||
|
sinon.restore();
|
||||||
|
|
||||||
SyncedTabs._internal.isConfiguredToSyncTabs = true;
|
setupSyncedTabsStubs({
|
||||||
|
signedInUser: {verified: true},
|
||||||
|
loginFailed: false,
|
||||||
|
isConfiguredToSyncTabs: true,
|
||||||
|
hasSyncedThisSession: false,
|
||||||
|
tabClients: [],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("tabs-fetching"),
|
Assert.ok(selectedPanel.classList.contains("tabs-fetching"),
|
||||||
"tabs fetch panel is selected");
|
"tabs fetch panel is selected");
|
||||||
|
sinon.restore();
|
||||||
|
|
||||||
SyncedTabs._internal.hasSyncedThisSession = true;
|
setupSyncedTabsStubs({
|
||||||
sinon.stub(SyncedTabs._internal, "getTabClients", () => Promise.resolve([]));
|
signedInUser: {verified: true},
|
||||||
|
loginFailed: false,
|
||||||
|
isConfiguredToSyncTabs: true,
|
||||||
|
hasSyncedThisSession: true,
|
||||||
|
tabClients: [],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("singleDeviceInfo"),
|
Assert.ok(selectedPanel.classList.contains("singleDeviceInfo"),
|
||||||
"tabs fetch panel is selected");
|
"tabs fetch panel is selected");
|
||||||
|
sinon.restore();
|
||||||
|
|
||||||
SyncedTabs._internal.getTabClients.restore();
|
setupSyncedTabsStubs({
|
||||||
sinon.stub(SyncedTabs._internal, "getTabClients", () => Promise.resolve([{id: "mock"}]));
|
signedInUser: {verified: true},
|
||||||
|
loginFailed: false,
|
||||||
|
isConfiguredToSyncTabs: true,
|
||||||
|
hasSyncedThisSession: true,
|
||||||
|
tabClients: [{id: "mock"}],
|
||||||
|
});
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
selectedPanel = syncedTabsDeckComponent.container.querySelector(".sync-state.selected");
|
||||||
Assert.ok(selectedPanel.classList.contains("tabs-container"),
|
Assert.ok(selectedPanel.classList.contains("tabs-container"),
|
||||||
|
|
@ -275,16 +301,7 @@ add_task(async function testSyncedTabsSidebarContextMenu() {
|
||||||
|
|
||||||
Assert.ok(syncedTabsDeckComponent, "component exists");
|
Assert.ok(syncedTabsDeckComponent, "component exists");
|
||||||
|
|
||||||
originalSyncedTabsInternal = SyncedTabs._internal;
|
setupSyncedTabsStubs();
|
||||||
SyncedTabs._internal = {
|
|
||||||
isConfiguredToSyncTabs: true,
|
|
||||||
hasSyncedThisSession: true,
|
|
||||||
getTabClients() { return Promise.resolve([]); },
|
|
||||||
syncTabs() { return Promise.resolve(); },
|
|
||||||
};
|
|
||||||
|
|
||||||
sinon.stub(syncedTabsDeckComponent, "_getSignedInUser", () => Promise.resolve({verified: true}));
|
|
||||||
sinon.stub(SyncedTabs._internal, "getTabClients", () => Promise.resolve(Cu.cloneInto(FIXTURE, {})));
|
|
||||||
|
|
||||||
await syncedTabsDeckComponent.updatePanel();
|
await syncedTabsDeckComponent.updatePanel();
|
||||||
// This is a hacky way of waiting for the view to render. The view renders
|
// This is a hacky way of waiting for the view to render. The view renders
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,3 @@
|
||||||
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/docs/
|
|
||||||
/* global sinon */
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
registerCleanupFunction(async function() {
|
|
||||||
// Cleanup window or the test runner will throw an error
|
|
||||||
delete window.sinon;
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,9 @@
|
||||||
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
|
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
|
||||||
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
|
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
|
||||||
});
|
});
|
||||||
|
|
||||||
do_get_profile(); // fxa needs a profile directory for storage.
|
do_get_profile(); // fxa needs a profile directory for storage.
|
||||||
|
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ add_task(async function testInitUninit() {
|
||||||
let view = {render: sinon.spy(), destroy: sinon.spy(), container: {}};
|
let view = {render: sinon.spy(), destroy: sinon.spy(), container: {}};
|
||||||
ViewMock.returns(view);
|
ViewMock.returns(view);
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "syncTabs", () => Promise.resolve());
|
sinon.stub(SyncedTabs, "syncTabs").callsFake(() => Promise.resolve());
|
||||||
|
|
||||||
sinon.spy(deckStore, "on");
|
sinon.spy(deckStore, "on");
|
||||||
sinon.stub(deckStore, "setPanels");
|
sinon.stub(deckStore, "setPanels");
|
||||||
|
|
@ -85,7 +85,7 @@ add_task(async function testObserver() {
|
||||||
let view = {render: sinon.spy(), destroy: sinon.spy(), container: {}};
|
let view = {render: sinon.spy(), destroy: sinon.spy(), container: {}};
|
||||||
ViewMock.returns(view);
|
ViewMock.returns(view);
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "syncTabs", () => Promise.resolve());
|
sinon.stub(SyncedTabs, "syncTabs").callsFake(() => Promise.resolve());
|
||||||
|
|
||||||
sinon.spy(deckStore, "on");
|
sinon.spy(deckStore, "on");
|
||||||
sinon.stub(deckStore, "setPanels");
|
sinon.stub(deckStore, "setPanels");
|
||||||
|
|
@ -162,7 +162,7 @@ add_task(async function testPanelStatus() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let account = null;
|
let account = null;
|
||||||
sinon.stub(fxAccounts, "getSignedInUser", () => Promise.resolve(account));
|
sinon.stub(fxAccounts, "getSignedInUser").callsFake(() => Promise.resolve(account));
|
||||||
let result = await component.getPanelStatus();
|
let result = await component.getPanelStatus();
|
||||||
Assert.equal(result, component.PANELS.NOT_AUTHED_INFO);
|
Assert.equal(result, component.PANELS.NOT_AUTHED_INFO);
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ add_task(async function testPanelStatus() {
|
||||||
SyncedTabsMock.hasSyncedThisSession = true;
|
SyncedTabsMock.hasSyncedThisSession = true;
|
||||||
|
|
||||||
let clients = [];
|
let clients = [];
|
||||||
sinon.stub(SyncedTabsMock, "getTabClients", () => Promise.resolve(clients));
|
sinon.stub(SyncedTabsMock, "getTabClients").callsFake(() => Promise.resolve(clients));
|
||||||
result = await component.getPanelStatus();
|
result = await component.getPanelStatus();
|
||||||
Assert.equal(result, component.PANELS.SINGLE_DEVICE_INFO);
|
Assert.equal(result, component.PANELS.SINGLE_DEVICE_INFO);
|
||||||
|
|
||||||
|
|
@ -200,11 +200,11 @@ add_task(async function testPanelStatus() {
|
||||||
Assert.equal(result, component.PANELS.TABS_CONTAINER);
|
Assert.equal(result, component.PANELS.TABS_CONTAINER);
|
||||||
|
|
||||||
fxAccounts.getSignedInUser.restore();
|
fxAccounts.getSignedInUser.restore();
|
||||||
sinon.stub(fxAccounts, "getSignedInUser", () => Promise.reject("err"));
|
sinon.stub(fxAccounts, "getSignedInUser").callsFake(() => Promise.reject("err"));
|
||||||
result = await component.getPanelStatus();
|
result = await component.getPanelStatus();
|
||||||
Assert.equal(result, component.PANELS.NOT_AUTHED_INFO);
|
Assert.equal(result, component.PANELS.NOT_AUTHED_INFO);
|
||||||
|
|
||||||
sinon.stub(component, "getPanelStatus", () => Promise.resolve("mock-panelId"));
|
sinon.stub(component, "getPanelStatus").callsFake(() => Promise.resolve("mock-panelId"));
|
||||||
sinon.spy(deckStore, "selectPanel");
|
sinon.spy(deckStore, "selectPanel");
|
||||||
await component.updatePanel();
|
await component.updatePanel();
|
||||||
Assert.ok(deckStore.selectPanel.calledWith("mock-panelId"));
|
Assert.ok(deckStore.selectPanel.calledWith("mock-panelId"));
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ add_task(async function testGetDataEmpty() {
|
||||||
let store = new SyncedTabsListStore(SyncedTabs);
|
let store = new SyncedTabsListStore(SyncedTabs);
|
||||||
let spy = sinon.spy();
|
let spy = sinon.spy();
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "getTabClients", () => {
|
sinon.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
});
|
});
|
||||||
store.on("change", spy);
|
store.on("change", spy);
|
||||||
|
|
@ -77,7 +77,7 @@ add_task(async function testRowSelectionWithoutFilter() {
|
||||||
let store = new SyncedTabsListStore(SyncedTabs);
|
let store = new SyncedTabsListStore(SyncedTabs);
|
||||||
let spy = sinon.spy();
|
let spy = sinon.spy();
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "getTabClients", () => {
|
sinon.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
return Promise.resolve(FIXTURE);
|
return Promise.resolve(FIXTURE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ add_task(async function testToggleBranches() {
|
||||||
let store = new SyncedTabsListStore(SyncedTabs);
|
let store = new SyncedTabsListStore(SyncedTabs);
|
||||||
let spy = sinon.spy();
|
let spy = sinon.spy();
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "getTabClients", () => {
|
sinon.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
return Promise.resolve(FIXTURE);
|
return Promise.resolve(FIXTURE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ add_task(async function testRowSelectionWithFilter() {
|
||||||
let store = new SyncedTabsListStore(SyncedTabs);
|
let store = new SyncedTabsListStore(SyncedTabs);
|
||||||
let spy = sinon.spy();
|
let spy = sinon.spy();
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "getTabClients", () => {
|
sinon.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
return Promise.resolve(FIXTURE);
|
return Promise.resolve(FIXTURE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ add_task(async function testFilterAndClearFilter() {
|
||||||
let store = new SyncedTabsListStore(SyncedTabs);
|
let store = new SyncedTabsListStore(SyncedTabs);
|
||||||
let spy = sinon.spy();
|
let spy = sinon.spy();
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "getTabClients", () => {
|
sinon.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
return Promise.resolve(FIXTURE);
|
return Promise.resolve(FIXTURE);
|
||||||
});
|
});
|
||||||
store.on("change", spy);
|
store.on("change", spy);
|
||||||
|
|
@ -230,7 +230,7 @@ add_task(async function testFocusBlurInput() {
|
||||||
let store = new SyncedTabsListStore(SyncedTabs);
|
let store = new SyncedTabsListStore(SyncedTabs);
|
||||||
let spy = sinon.spy();
|
let spy = sinon.spy();
|
||||||
|
|
||||||
sinon.stub(SyncedTabs, "getTabClients", () => {
|
sinon.stub(SyncedTabs, "getTabClients").callsFake(() => {
|
||||||
return Promise.resolve(FIXTURE);
|
return Promise.resolve(FIXTURE);
|
||||||
});
|
});
|
||||||
store.on("change", spy);
|
store.on("change", spy);
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,5 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
/* exported sinon */
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
||||||
var gProfD = do_get_profile().QueryInterface(Ci.nsIFile);
|
var gProfD = do_get_profile().QueryInterface(Ci.nsIFile);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ async function withNewWindow(callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
fakeController = new UrlbarController({
|
fakeController = new UrlbarController({
|
||||||
browserWindow: window,
|
browserWindow: window,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
// original search query.
|
// original search query.
|
||||||
|
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
registerCleanupFunction(async () => {
|
registerCleanupFunction(async () => {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ const REMOTE_TAB = {
|
||||||
};
|
};
|
||||||
|
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
let originalSyncedTabsInternal = SyncedTabs._internal;
|
let originalSyncedTabsInternal = SyncedTabs._internal;
|
||||||
SyncedTabs._internal = {
|
SyncedTabs._internal = {
|
||||||
|
|
@ -54,7 +54,7 @@ add_task(async function setup() {
|
||||||
["services.sync.syncedTabs.showRemoteTabs", true],
|
["services.sync.syncedTabs.showRemoteTabs", true],
|
||||||
]});
|
]});
|
||||||
|
|
||||||
sandbox.stub(SyncedTabs._internal, "getTabClients", () => Promise.resolve(Cu.cloneInto([REMOTE_TAB], {})));
|
sandbox.stub(SyncedTabs._internal, "getTabClients").callsFake(() => Promise.resolve(Cu.cloneInto([REMOTE_TAB], {})));
|
||||||
|
|
||||||
registerCleanupFunction(async () => {
|
registerCleanupFunction(async () => {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,4 @@ Services.scriptloader.loadSubScript(
|
||||||
"chrome://mochitests/content/browser/browser/components/urlbar/tests/browser/head-common.js",
|
"chrome://mochitests/content/browser/browser/components/urlbar/tests/browser/head-common.js",
|
||||||
this);
|
this);
|
||||||
|
|
||||||
/* global sinon */
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
registerCleanupFunction(function() {
|
|
||||||
delete window.sinon;
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||||
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
|
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
|
||||||
});
|
});
|
||||||
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
// Sinon needs Timer.jsm for setTimeout etc.
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} searchString The search string to insert into the context.
|
* @param {string} searchString The search string to insert into the context.
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function assertContextMatches(context, expectedValues) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(function setup() {
|
add_task(function setup() {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
fPM = {
|
fPM = {
|
||||||
startQuery: sandbox.stub(),
|
startQuery: sandbox.stub(),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const {PlacesUIUtils} = ChromeUtils.import("resource:///modules/PlacesUIUtils.js
|
||||||
let sandbox;
|
let sandbox;
|
||||||
|
|
||||||
add_task(function setup() {
|
add_task(function setup() {
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.createSandbox();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_addToUrlbarHistory() {
|
add_task(function test_addToUrlbarHistory() {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ var {AddonTestUtils, MockAsyncShutdown} = ChromeUtils.import("resource://testing
|
||||||
var {ExtensionTestUtils} = ChromeUtils.import("resource://testing-common/ExtensionXPCShellUtils.jsm");
|
var {ExtensionTestUtils} = ChromeUtils.import("resource://testing-common/ExtensionXPCShellUtils.jsm");
|
||||||
var {FileTestUtils} = ChromeUtils.import("resource://testing-common/FileTestUtils.jsm");
|
var {FileTestUtils} = ChromeUtils.import("resource://testing-common/FileTestUtils.jsm");
|
||||||
var {MockDocument} = ChromeUtils.import("resource://testing-common/MockDocument.jsm");
|
var {MockDocument} = ChromeUtils.import("resource://testing-common/MockDocument.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
var {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
|
var {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "AddonManager",
|
ChromeUtils.defineModuleGetter(this, "AddonManager",
|
||||||
|
|
@ -58,21 +59,6 @@ region-name-tw = Taiwan
|
||||||
|
|
||||||
do_get_profile();
|
do_get_profile();
|
||||||
|
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
var {
|
|
||||||
clearInterval,
|
|
||||||
clearTimeout,
|
|
||||||
setInterval,
|
|
||||||
setIntervalWithTarget,
|
|
||||||
setTimeout,
|
|
||||||
setTimeoutWithTarget,
|
|
||||||
} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
||||||
const EXTENSION_ID = "formautofill@mozilla.org";
|
const EXTENSION_ID = "formautofill@mozilla.org";
|
||||||
|
|
||||||
AddonTestUtils.init(this);
|
AddonTestUtils.init(this);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ add_task(async function test_activeStatus_observe() {
|
||||||
|
|
||||||
// _active != _computeStatus() => Need to trigger _onStatusChanged
|
// _active != _computeStatus() => Need to trigger _onStatusChanged
|
||||||
formAutofillParent._computeStatus.returns(false);
|
formAutofillParent._computeStatus.returns(false);
|
||||||
formAutofillParent._onStatusChanged.reset();
|
formAutofillParent._onStatusChanged.resetHistory();
|
||||||
formAutofillParent.observe(null, "nsPref:changed", "extensions.formautofill.addresses.enabled");
|
formAutofillParent.observe(null, "nsPref:changed", "extensions.formautofill.addresses.enabled");
|
||||||
formAutofillParent.observe(null, "nsPref:changed", "extensions.formautofill.creditCards.enabled");
|
formAutofillParent.observe(null, "nsPref:changed", "extensions.formautofill.creditCards.enabled");
|
||||||
Assert.equal(formAutofillParent._onStatusChanged.called, true);
|
Assert.equal(formAutofillParent._onStatusChanged.called, true);
|
||||||
|
|
@ -55,14 +55,14 @@ add_task(async function test_activeStatus_observe() {
|
||||||
// profile changed => Need to trigger _onStatusChanged
|
// profile changed => Need to trigger _onStatusChanged
|
||||||
await Promise.all(["add", "update", "remove", "reconcile"].map(async event => {
|
await Promise.all(["add", "update", "remove", "reconcile"].map(async event => {
|
||||||
formAutofillParent._computeStatus.returns(!formAutofillParent._active);
|
formAutofillParent._computeStatus.returns(!formAutofillParent._active);
|
||||||
formAutofillParent._onStatusChanged.reset();
|
formAutofillParent._onStatusChanged.resetHistory();
|
||||||
await formAutofillParent.observe(null, "formautofill-storage-changed", event);
|
await formAutofillParent.observe(null, "formautofill-storage-changed", event);
|
||||||
Assert.equal(formAutofillParent._onStatusChanged.called, true);
|
Assert.equal(formAutofillParent._onStatusChanged.called, true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// profile metadata updated => No need to trigger _onStatusChanged
|
// profile metadata updated => No need to trigger _onStatusChanged
|
||||||
formAutofillParent._computeStatus.returns(!formAutofillParent._active);
|
formAutofillParent._computeStatus.returns(!formAutofillParent._active);
|
||||||
formAutofillParent._onStatusChanged.reset();
|
formAutofillParent._onStatusChanged.resetHistory();
|
||||||
await formAutofillParent.observe(null, "formautofill-storage-changed", "notifyUsed");
|
await formAutofillParent.observe(null, "formautofill-storage-changed", "notifyUsed");
|
||||||
Assert.equal(formAutofillParent._onStatusChanged.called, false);
|
Assert.equal(formAutofillParent._onStatusChanged.called, false);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ add_task(async function test_loadDataState() {
|
||||||
Assert.equal(metadata.id, "data/US");
|
Assert.equal(metadata.id, "data/US");
|
||||||
Assert.ok(metadata.alternative_names,
|
Assert.ok(metadata.alternative_names,
|
||||||
"US alternative names should be loaded from extension");
|
"US alternative names should be loaded from extension");
|
||||||
AddressDataLoader._loadScripts.reset();
|
AddressDataLoader._loadScripts.resetHistory();
|
||||||
|
|
||||||
// Load data without country
|
// Load data without country
|
||||||
let newMetadata = FormAutofillUtils.getCountryAddressData();
|
let newMetadata = FormAutofillUtils.getCountryAddressData();
|
||||||
// _loadScripts should not be called
|
// _loadScripts should not be called
|
||||||
sinon.assert.notCalled(AddressDataLoader._loadScripts);
|
sinon.assert.notCalled(AddressDataLoader._loadScripts);
|
||||||
Assert.deepEqual(metadata, newMetadata, "metadata should be US if country is not specified");
|
Assert.deepEqual(metadata, newMetadata, "metadata should be US if country is not specified");
|
||||||
AddressDataLoader._loadScripts.reset();
|
AddressDataLoader._loadScripts.resetHistory();
|
||||||
|
|
||||||
// Load level 1 data that does not exist
|
// Load level 1 data that does not exist
|
||||||
let undefinedMetadata = FormAutofillUtils.getCountryAddressData("US", "CA");
|
let undefinedMetadata = FormAutofillUtils.getCountryAddressData("US", "CA");
|
||||||
|
|
@ -57,7 +57,7 @@ add_task(async function test_loadDataState() {
|
||||||
Assert.equal(undefinedMetadata, undefined, "metadata should be undefined");
|
Assert.equal(undefinedMetadata, undefined, "metadata should be undefined");
|
||||||
Assert.ok(AddressDataLoader._dataLoaded.level1.has("US"),
|
Assert.ok(AddressDataLoader._dataLoaded.level1.has("US"),
|
||||||
"level 1 state array should be set even there's no valid metadata");
|
"level 1 state array should be set even there's no valid metadata");
|
||||||
AddressDataLoader._loadScripts.reset();
|
AddressDataLoader._loadScripts.resetHistory();
|
||||||
|
|
||||||
// Load level 1 data again
|
// Load level 1 data again
|
||||||
undefinedMetadata = FormAutofillUtils.getCountryAddressData("US", "AS");
|
undefinedMetadata = FormAutofillUtils.getCountryAddressData("US", "AS");
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const {setTimeout, clearTimeout} = ChromeUtils.import("resource://gre/modules/Timer.jsm", {});
|
||||||
|
|
||||||
var FormAutofillHandler, OSKeyStore;
|
var FormAutofillHandler, OSKeyStore;
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
({FormAutofillHandler} = ChromeUtils.import("resource://formautofill/FormAutofillHandler.jsm"));
|
({FormAutofillHandler} = ChromeUtils.import("resource://formautofill/FormAutofillHandler.jsm"));
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ add_task(async function test_getRecords_creditCards() {
|
||||||
clonedRecord["cc-number-encrypted"] = await OSKeyStore.encrypt(record["cc-number"]);
|
clonedRecord["cc-number-encrypted"] = await OSKeyStore.encrypt(record["cc-number"]);
|
||||||
return clonedRecord;
|
return clonedRecord;
|
||||||
}));
|
}));
|
||||||
sinon.stub(collection, "getAll", () =>
|
sinon.stub(collection, "getAll").callsFake(() =>
|
||||||
Promise.resolve([Object.assign({}, encryptedCCRecords[0]), Object.assign({}, encryptedCCRecords[1])]));
|
Promise.resolve([Object.assign({}, encryptedCCRecords[0]), Object.assign({}, encryptedCCRecords[1])]));
|
||||||
|
|
||||||
let testCases = [
|
let testCases = [
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,7 @@ add_task(async function autofill_disabled() {
|
||||||
Services.prefs.setBoolPref("extensions.formautofill.creditCards.enabled", false);
|
Services.prefs.setBoolPref("extensions.formautofill.creditCards.enabled", false);
|
||||||
FormAutofillContent.formSubmitted(form, null);
|
FormAutofillContent.formSubmitted(form, null);
|
||||||
Assert.equal(FormAutofillContent._onFormSubmit.called, false);
|
Assert.equal(FormAutofillContent._onFormSubmit.called, false);
|
||||||
FormAutofillContent._onFormSubmit.reset();
|
FormAutofillContent._onFormSubmit.resetHistory();
|
||||||
|
|
||||||
// "_onFormSubmit" should be called as usual.
|
// "_onFormSubmit" should be called as usual.
|
||||||
Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");
|
Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");
|
||||||
|
|
@ -536,7 +536,7 @@ add_task(async function autofill_disabled() {
|
||||||
Assert.equal(FormAutofillContent._onFormSubmit.called, true);
|
Assert.equal(FormAutofillContent._onFormSubmit.called, true);
|
||||||
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
|
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
|
||||||
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].creditCard, []);
|
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].creditCard, []);
|
||||||
FormAutofillContent._onFormSubmit.reset();
|
FormAutofillContent._onFormSubmit.resetHistory();
|
||||||
|
|
||||||
// "address" should be empty if "addresses" pref is disabled.
|
// "address" should be empty if "addresses" pref is disabled.
|
||||||
Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", false);
|
Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", false);
|
||||||
|
|
@ -544,7 +544,7 @@ add_task(async function autofill_disabled() {
|
||||||
Assert.equal(FormAutofillContent._onFormSubmit.called, true);
|
Assert.equal(FormAutofillContent._onFormSubmit.called, true);
|
||||||
Assert.deepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
|
Assert.deepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
|
||||||
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].creditCard, []);
|
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].creditCard, []);
|
||||||
FormAutofillContent._onFormSubmit.reset();
|
FormAutofillContent._onFormSubmit.resetHistory();
|
||||||
Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");
|
Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");
|
||||||
|
|
||||||
// "creditCard" should be empty if "creditCards" pref is disabled.
|
// "creditCard" should be empty if "creditCards" pref is disabled.
|
||||||
|
|
@ -553,7 +553,7 @@ add_task(async function autofill_disabled() {
|
||||||
Assert.deepEqual(FormAutofillContent._onFormSubmit.called, true);
|
Assert.deepEqual(FormAutofillContent._onFormSubmit.called, true);
|
||||||
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
|
Assert.notDeepEqual(FormAutofillContent._onFormSubmit.args[0][0].address, []);
|
||||||
Assert.deepEqual(FormAutofillContent._onFormSubmit.args[0][0].creditCard, []);
|
Assert.deepEqual(FormAutofillContent._onFormSubmit.args[0][0].creditCard, []);
|
||||||
FormAutofillContent._onFormSubmit.reset();
|
FormAutofillContent._onFormSubmit.resetHistory();
|
||||||
Services.prefs.clearUserPref("extensions.formautofill.creditCards.enabled");
|
Services.prefs.clearUserPref("extensions.formautofill.creditCards.enabled");
|
||||||
|
|
||||||
FormAutofillContent._onFormSubmit.restore();
|
FormAutofillContent._onFormSubmit.restore();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ add_task(async function test_profileSavedFieldNames_observe() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// profile metadata updated => no need to trigger updateValidFields
|
// profile metadata updated => no need to trigger updateValidFields
|
||||||
formAutofillParent._updateSavedFieldNames.reset();
|
formAutofillParent._updateSavedFieldNames.resetHistory();
|
||||||
formAutofillParent.observe(null, "formautofill-storage-changed", "notifyUsed");
|
formAutofillParent.observe(null, "formautofill-storage-changed", "notifyUsed");
|
||||||
Assert.equal(formAutofillParent._updateSavedFieldNames.called, false);
|
Assert.equal(formAutofillParent._updateSavedFieldNames.called, false);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||||
URLBAR_SELECTED_RESULT_TYPES: "resource:///modules/BrowserUsageTelemetry.jsm",
|
URLBAR_SELECTED_RESULT_TYPES: "resource:///modules/BrowserUsageTelemetry.jsm",
|
||||||
URLBAR_SELECTED_RESULT_METHODS: "resource:///modules/BrowserUsageTelemetry.jsm",
|
URLBAR_SELECTED_RESULT_METHODS: "resource:///modules/BrowserUsageTelemetry.jsm",
|
||||||
});
|
});
|
||||||
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
|
|
||||||
function assertSearchTelemetryEmpty(search_hist) {
|
function assertSearchTelemetryEmpty(search_hist) {
|
||||||
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
|
||||||
|
|
@ -58,9 +59,6 @@ function assertHistogramResults(histograms, type, index, method) {
|
||||||
|
|
||||||
|
|
||||||
add_task(async function setup() {
|
add_task(async function setup() {
|
||||||
/* global sinon */
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [
|
set: [
|
||||||
// Disable search suggestions in the urlbar.
|
// Disable search suggestions in the urlbar.
|
||||||
|
|
@ -108,7 +106,7 @@ add_task(async function setup() {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
let originalSyncedTabsInternal = SyncedTabs._internal;
|
let originalSyncedTabsInternal = SyncedTabs._internal;
|
||||||
SyncedTabs._internal = {
|
SyncedTabs._internal = {
|
||||||
|
|
@ -137,7 +135,6 @@ add_task(async function setup() {
|
||||||
await PlacesUtils.history.clear();
|
await PlacesUtils.history.clear();
|
||||||
await PlacesUtils.bookmarks.eraseEverything();
|
await PlacesUtils.bookmarks.eraseEverything();
|
||||||
Services.telemetry.setEventRecordingEnabled("navigation", false);
|
Services.telemetry.setEventRecordingEnabled("navigation", false);
|
||||||
delete window.sinon;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ Test that Accordion renders correctly.
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Accordion component test</title>
|
<title>Accordion component test</title>
|
||||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="application/javascript" src="resource://testing-common/sinon-7.2.7.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||||
<link rel="stylesheet" href="chrome://devtools/skin/light-theme.css" type="text/css">
|
<link rel="stylesheet" href="chrome://devtools/skin/light-theme.css" type="text/css">
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -24,7 +25,6 @@ Test that Accordion renders correctly.
|
||||||
window.onload = async function() {
|
window.onload = async function() {
|
||||||
try {
|
try {
|
||||||
const { button, div } = require("devtools/client/shared/vendor/react-dom-factories");
|
const { button, div } = require("devtools/client/shared/vendor/react-dom-factories");
|
||||||
const sinon = require("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
const React = browserRequire("devtools/client/shared/vendor/react");
|
const React = browserRequire("devtools/client/shared/vendor/react");
|
||||||
const {
|
const {
|
||||||
Simulate,
|
Simulate,
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,3 @@
|
||||||
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
||||||
|
|
||||||
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
|
||||||
const Services = require("Services");
|
|
||||||
|
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
const {setTimeout, clearTimeout, setInterval, clearInterval} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
|
||||||
|
|
@ -2695,7 +2695,7 @@ pref("csp.overrule_about_uris_without_csp_whitelist", false);
|
||||||
pref("csp.skip_about_page_has_csp_assert", false);
|
pref("csp.skip_about_page_has_csp_assert", false);
|
||||||
// assertion flag will be set to false after fixing Bug 1473549
|
// assertion flag will be set to false after fixing Bug 1473549
|
||||||
pref("security.allow_eval_with_system_principal", false);
|
pref("security.allow_eval_with_system_principal", false);
|
||||||
pref("security.uris_using_eval_with_system_principal", "autocomplete.xml,redux.js,react-redux.js,content-task.js,content-task.js,tree.xml,dialog.xml,preferencesbindings.js,wizard.xml,lodash.js,jszip.js,ajv-4.1.1.js,updates.js,setup,jsol.js,parent_utils.js,chrometask_chromescript");
|
pref("security.uris_using_eval_with_system_principal", "autocomplete.xml,redux.js,react-redux.js,content-task.js,content-task.js,tree.xml,dialog.xml,preferencesbindings.js,wizard.xml,lodash.js,jszip.js,sinon-7.2.7.js,ajv-4.1.1.js,updates.js,setup,jsol.js,parent_utils.js,chrometask_chromescript");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Default Content Security Policy to apply to signed contents.
|
// Default Content Security Policy to apply to signed contents.
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,7 @@
|
||||||
|
|
||||||
const {Async} = ChromeUtils.import("resource://services-common/async.js");
|
const {Async} = ChromeUtils.import("resource://services-common/async.js");
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
// Sinon seems to require setTimeout.
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
const {setTimeout, clearTimeout, setInterval, clearInterval} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
|
|
||||||
function makeArray(length) {
|
function makeArray(length) {
|
||||||
// Start at 1 so that we can just divide by yieldEvery to get the expected
|
// Start at 1 so that we can just divide by yieldEvery to get the expected
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
|
|
||||||
(function initFxAccountsTestingInfrastructure() {
|
(function initFxAccountsTestingInfrastructure() {
|
||||||
do_get_profile();
|
do_get_profile();
|
||||||
|
|
@ -17,11 +18,3 @@ var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
ns.initTestLogging("Trace");
|
ns.initTestLogging("Trace");
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ const {ON_PROFILE_CHANGE_NOTIFICATION, log} = ChromeUtils.import("resource://gre
|
||||||
const {FxAccountsProfileClient} = ChromeUtils.import("resource://gre/modules/FxAccountsProfileClient.jsm");
|
const {FxAccountsProfileClient} = ChromeUtils.import("resource://gre/modules/FxAccountsProfileClient.jsm");
|
||||||
const {FxAccountsProfile} = ChromeUtils.import("resource://gre/modules/FxAccountsProfile.jsm");
|
const {FxAccountsProfile} = ChromeUtils.import("resource://gre/modules/FxAccountsProfile.jsm");
|
||||||
const {PromiseUtils} = ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
|
const {PromiseUtils} = ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
|
||||||
|
const {setTimeout} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||||
|
|
||||||
let mockClient = function(fxa) {
|
let mockClient = function(fxa) {
|
||||||
let options = {
|
let options = {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ var {AddonTestUtils, MockAsyncShutdown} = ChromeUtils.import("resource://testing
|
||||||
var {Async} = ChromeUtils.import("resource://services-common/async.js");
|
var {Async} = ChromeUtils.import("resource://services-common/async.js");
|
||||||
var {CommonUtils} = ChromeUtils.import("resource://services-common/utils.js");
|
var {CommonUtils} = ChromeUtils.import("resource://services-common/utils.js");
|
||||||
var {PlacesTestUtils} = ChromeUtils.import("resource://testing-common/PlacesTestUtils.jsm");
|
var {PlacesTestUtils} = ChromeUtils.import("resource://testing-common/PlacesTestUtils.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
var {SerializableSet, Svc, Utils, getChromeWindow} = ChromeUtils.import("resource://services-sync/util.js");
|
var {SerializableSet, Svc, Utils, getChromeWindow} = ChromeUtils.import("resource://services-sync/util.js");
|
||||||
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
var {PlacesUtils} = ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm");
|
var {PlacesUtils} = ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||||
|
|
@ -33,14 +34,6 @@ add_task(async function head_setup() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "SyncPingSchema", function() {
|
XPCOMUtils.defineLazyGetter(this, "SyncPingSchema", function() {
|
||||||
let ns = {};
|
let ns = {};
|
||||||
ChromeUtils.import("resource://gre/modules/FileUtils.jsm", ns);
|
ChromeUtils.import("resource://gre/modules/FileUtils.jsm", ns);
|
||||||
|
|
|
||||||
|
|
@ -1584,7 +1584,7 @@ add_task(async function test_command_sync() {
|
||||||
|
|
||||||
await engine.sendCommand("wipeAll", []);
|
await engine.sendCommand("wipeAll", []);
|
||||||
await engine._tracker.addChangedID(engine.localID);
|
await engine._tracker.addChangedID(engine.localID);
|
||||||
const getClientFxaDeviceId = sinon.stub(engine, "getClientFxaDeviceId", (id) => "fxa-" + id);
|
const getClientFxaDeviceId = sinon.stub(engine, "getClientFxaDeviceId").callsFake((id) => "fxa-" + id);
|
||||||
const engineMock = sinon.mock(engine);
|
const engineMock = sinon.mock(engine);
|
||||||
let _notifyCollectionChanged = engineMock.expects("_notifyCollectionChanged")
|
let _notifyCollectionChanged = engineMock.expects("_notifyCollectionChanged")
|
||||||
.withArgs(["fxa-" + remoteId, "fxa-" + remoteId2]);
|
.withArgs(["fxa-" + remoteId, "fxa-" + remoteId2]);
|
||||||
|
|
@ -1796,7 +1796,7 @@ add_task(async function device_disconnected_notification_updates_known_stale_cli
|
||||||
Services.obs.notifyObservers(null, "fxaccounts:device_disconnected",
|
Services.obs.notifyObservers(null, "fxaccounts:device_disconnected",
|
||||||
JSON.stringify({ isLocalDevice: false }));
|
JSON.stringify({ isLocalDevice: false }));
|
||||||
ok(spyUpdate.calledOnce, "updateKnownStaleClients should be called");
|
ok(spyUpdate.calledOnce, "updateKnownStaleClients should be called");
|
||||||
spyUpdate.reset();
|
spyUpdate.resetHistory();
|
||||||
|
|
||||||
Services.obs.notifyObservers(null, "fxaccounts:device_disconnected",
|
Services.obs.notifyObservers(null, "fxaccounts:device_disconnected",
|
||||||
JSON.stringify({ isLocalDevice: true }));
|
JSON.stringify({ isLocalDevice: true }));
|
||||||
|
|
@ -1811,7 +1811,7 @@ add_task(async function update_known_stale_clients() {
|
||||||
const stubRemoteClients = sinon.stub(engine._store, "_remoteClients").get(() => {
|
const stubRemoteClients = sinon.stub(engine._store, "_remoteClients").get(() => {
|
||||||
return clients;
|
return clients;
|
||||||
});
|
});
|
||||||
const stubFetchFxADevices = sinon.stub(engine, "_fetchFxADevices", () => {
|
const stubFetchFxADevices = sinon.stub(engine, "_fetchFxADevices").callsFake(() => {
|
||||||
engine._knownStaleFxADeviceIds = ["fxa-one", "fxa-two"];
|
engine._knownStaleFxADeviceIds = ["fxa-one", "fxa-two"];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1835,7 +1835,7 @@ add_task(async function test_create_record_command_limit() {
|
||||||
const fakeLimit = 4 * 1024;
|
const fakeLimit = 4 * 1024;
|
||||||
|
|
||||||
let maxSizeStub = sinon.stub(Service,
|
let maxSizeStub = sinon.stub(Service,
|
||||||
"getMemcacheMaxRecordPayloadSize", () => fakeLimit);
|
"getMemcacheMaxRecordPayloadSize").callsFake(() => fakeLimit);
|
||||||
|
|
||||||
let user = server.user("foo");
|
let user = server.user("foo");
|
||||||
let remoteId = Utils.makeGUID();
|
let remoteId = Utils.makeGUID();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
/* global sinon */
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ add_task(async function test_createRecord() {
|
||||||
// actual max we can fit.
|
// actual max we can fit.
|
||||||
equal(record.tabs.length, 2672);
|
equal(record.tabs.length, 2672);
|
||||||
|
|
||||||
let maxSizeStub = sinon.stub(Service, "getMemcacheMaxRecordPayloadSize", () => 512 * 1024);
|
let maxSizeStub = sinon.stub(Service, "getMemcacheMaxRecordPayloadSize").callsFake(() => 512 * 1024);
|
||||||
try {
|
try {
|
||||||
numtabs = 5400;
|
numtabs = 5400;
|
||||||
_("Modify the max record payload size and create a big record");
|
_("Modify the max record payload size and create a big record");
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ add_task(async function test_isReady_unconfigured() {
|
||||||
// Does not trigger a refresh of the state since services.sync.username is undefined
|
// Does not trigger a refresh of the state since services.sync.username is undefined
|
||||||
ok(!UIState.isReady());
|
ok(!UIState.isReady());
|
||||||
ok(!refreshState.called);
|
ok(!refreshState.called);
|
||||||
refreshState.reset();
|
refreshState.resetHistory();
|
||||||
|
|
||||||
// On subsequent calls, only return true
|
// On subsequent calls, only return true
|
||||||
ok(UIState.isReady());
|
ok(UIState.isReady());
|
||||||
|
|
@ -34,7 +34,7 @@ add_task(async function test_isReady_signedin() {
|
||||||
// On the first call, returns false and triggers a refresh of the state
|
// On the first call, returns false and triggers a refresh of the state
|
||||||
ok(!UIState.isReady());
|
ok(!UIState.isReady());
|
||||||
ok(refreshState.calledOnce);
|
ok(refreshState.calledOnce);
|
||||||
refreshState.reset();
|
refreshState.resetHistory();
|
||||||
|
|
||||||
// On subsequent calls, only return true
|
// On subsequent calls, only return true
|
||||||
ok(UIState.isReady());
|
ok(UIState.isReady());
|
||||||
|
|
@ -240,7 +240,7 @@ add_task(async function test_observer_refreshState() {
|
||||||
Services.obs.notifyObservers(null, topic);
|
Services.obs.notifyObservers(null, topic);
|
||||||
await uiUpdateObserved;
|
await uiUpdateObserved;
|
||||||
ok(refreshState.calledOnce);
|
ok(refreshState.calledOnce);
|
||||||
refreshState.reset();
|
refreshState.resetHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshState.restore();
|
refreshState.restore();
|
||||||
|
|
|
||||||
22
testing/modules/Sinon.jsm
Normal file
22
testing/modules/Sinon.jsm
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var EXPORTED_SYMBOLS = ["sinon"];
|
||||||
|
|
||||||
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
// ================================================
|
||||||
|
// Load mocking/stubbing library sinon
|
||||||
|
// docs: http://sinonjs.org/releases/v7.2.7/
|
||||||
|
const {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const global = {
|
||||||
|
clearInterval,
|
||||||
|
clearTimeout,
|
||||||
|
setInterval,
|
||||||
|
setIntervalWithTarget,
|
||||||
|
setTimeout,
|
||||||
|
setTimeoutWithTarget,
|
||||||
|
};
|
||||||
|
Services.scriptloader.loadSubScript("resource://testing-common/sinon-7.2.7.js", this);
|
||||||
|
const sinon = global.sinon;
|
||||||
|
// ================================================
|
||||||
|
|
@ -15,7 +15,8 @@ TESTING_JS_MODULES += [
|
||||||
'CoverageUtils.jsm',
|
'CoverageUtils.jsm',
|
||||||
'FileTestUtils.jsm',
|
'FileTestUtils.jsm',
|
||||||
'MockRegistrar.jsm',
|
'MockRegistrar.jsm',
|
||||||
'sinon-2.3.2.js',
|
'sinon-7.2.7.js',
|
||||||
|
'Sinon.jsm',
|
||||||
'StructuredLog.jsm',
|
'StructuredLog.jsm',
|
||||||
'TestUtils.jsm',
|
'TestUtils.jsm',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
31787
testing/modules/sinon-7.2.7.js
Normal file
31787
testing/modules/sinon-7.2.7.js
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,9 +1,2 @@
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* global sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ add_task(async function testDoNotTrack() {
|
||||||
add_task(async function testExperiments() {
|
add_task(async function testExperiments() {
|
||||||
const active = {name: "active", expired: false};
|
const active = {name: "active", expired: false};
|
||||||
const expired = {name: "expired", expired: true};
|
const expired = {name: "expired", expired: true};
|
||||||
const getAll = sinon.stub(PreferenceExperiments, "getAll", async () => [active, expired]);
|
const getAll = sinon.stub(PreferenceExperiments, "getAll").callsFake(async () => [active, expired]);
|
||||||
|
|
||||||
const experiments = await ClientEnvironment.experiments;
|
const experiments = await ClientEnvironment.experiments;
|
||||||
Assert.deepEqual(
|
Assert.deepEqual(
|
||||||
|
|
|
||||||
|
|
@ -140,10 +140,7 @@ async function withMockActionSandboxManagers(actions, testFunction) {
|
||||||
sinon.stub(managers[action.name], "runAsyncCallback");
|
sinon.stub(managers[action.name], "runAsyncCallback");
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadActionSandboxManagers = sinon.stub(RecipeRunner, "loadActionSandboxManagers")
|
|
||||||
.resolves(managers);
|
|
||||||
await testFunction(managers);
|
await testFunction(managers);
|
||||||
loadActionSandboxManagers.restore();
|
|
||||||
|
|
||||||
for (const manager of Object.values(managers)) {
|
for (const manager of Object.values(managers)) {
|
||||||
manager.removeHold("testing");
|
manager.removeHold("testing");
|
||||||
|
|
@ -359,9 +356,8 @@ decorate_task(
|
||||||
withStub(RecipeRunner, "enable"),
|
withStub(RecipeRunner, "enable"),
|
||||||
withStub(RecipeRunner, "disable"),
|
withStub(RecipeRunner, "disable"),
|
||||||
withStub(CleanupManager, "addCleanupHandler"),
|
withStub(CleanupManager, "addCleanupHandler"),
|
||||||
withStub(AddonStudies, "stop"),
|
|
||||||
|
|
||||||
async function testPrefWatching(runStub, enableStub, disableStub, addCleanupHandlerStub, stopStub) {
|
async function testPrefWatching(runStub, enableStub, disableStub, addCleanupHandlerStub) {
|
||||||
await RecipeRunner.init();
|
await RecipeRunner.init();
|
||||||
is(enableStub.callCount, 1, "Enable should be called initially");
|
is(enableStub.callCount, 1, "Enable should be called initially");
|
||||||
is(disableStub.callCount, 0, "Disable should not be called initially");
|
is(disableStub.callCount, 0, "Disable should not be called initially");
|
||||||
|
|
|
||||||
|
|
@ -245,10 +245,10 @@ decorate_task(
|
||||||
{ value: "branch0", ratio: 1 },
|
{ value: "branch0", ratio: 1 },
|
||||||
{ value: "branch1", ratio: 2 },
|
{ value: "branch1", ratio: 2 },
|
||||||
];
|
];
|
||||||
const sandbox = sinon.sandbox.create();
|
const sandbox = sinon.createSandbox();
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
sandbox.stub(ClientEnvironment, "userId", { get: () => "fake-id" });
|
sandbox.stub(ClientEnvironment, "userId").get(() => "fake-id");
|
||||||
result = await action.chooseBranch("exp-slug", branches);
|
result = await action.chooseBranch("exp-slug", branches);
|
||||||
} finally {
|
} finally {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,13 @@ const CryptoHash = Components.Constructor("@mozilla.org/security/hash;1",
|
||||||
const FileInputStream = Components.Constructor("@mozilla.org/network/file-input-stream;1",
|
const FileInputStream = Components.Constructor("@mozilla.org/network/file-input-stream;1",
|
||||||
"nsIFileInputStream", "init");
|
"nsIFileInputStream", "init");
|
||||||
|
|
||||||
// Load mocking/stubbing library, sinon
|
const {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// docs: http://sinonjs.org/docs/
|
|
||||||
/* global sinon */
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js");
|
|
||||||
|
|
||||||
// Make sinon assertions fail in a way that mochitest understands
|
// Make sinon assertions fail in a way that mochitest understands
|
||||||
sinon.assert.fail = function(message) {
|
sinon.assert.fail = function(message) {
|
||||||
ok(false, message);
|
ok(false, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerCleanupFunction(async function() {
|
|
||||||
// Cleanup window or the test runner will throw an error
|
|
||||||
delete window.sinon;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Prep Telemetry to receive events from tests
|
// Prep Telemetry to receive events from tests
|
||||||
TelemetryEvents.init();
|
TelemetryEvents.init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,4 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
var {sinon} = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||||
// ================================================
|
|
||||||
// Load mocking/stubbing library, sinon
|
|
||||||
// docs: http://sinonjs.org/releases/v2.3.2/
|
|
||||||
/* exported sinon */
|
|
||||||
var {clearInterval, clearTimeout, setInterval, setIntervalWithTarget, setTimeout, setTimeoutWithTarget} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
|
||||||
Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js", this);
|
|
||||||
/* globals sinon */
|
|
||||||
// ================================================
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ add_task(withMockApiServer(async function test_getApiUrl(serverUrl) {
|
||||||
|
|
||||||
add_task(withMockApiServer(async function test_getApiUrlSlashes(serverUrl, preferences) {
|
add_task(withMockApiServer(async function test_getApiUrlSlashes(serverUrl, preferences) {
|
||||||
const fakeResponse = new MockResponse(JSON.stringify({"test-endpoint": `${serverUrl}/test/`}));
|
const fakeResponse = new MockResponse(JSON.stringify({"test-endpoint": `${serverUrl}/test/`}));
|
||||||
const mockGet = sinon.stub(NormandyApi, "get", async () => fakeResponse);
|
const mockGet = sinon.stub(NormandyApi, "get").callsFake(async () => fakeResponse);
|
||||||
|
|
||||||
// without slash
|
// without slash
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,7 @@ add_task(withMockApiServer(async function test_getApiUrlSlashes(serverUrl, prefe
|
||||||
const endpoint = await NormandyApi.getApiUrl("test-endpoint");
|
const endpoint = await NormandyApi.getApiUrl("test-endpoint");
|
||||||
equal(endpoint, `${serverUrl}/test/`);
|
equal(endpoint, `${serverUrl}/test/`);
|
||||||
ok(mockGet.calledWithExactly(`${serverUrl}/api/v1/`), "trailing slash was added");
|
ok(mockGet.calledWithExactly(`${serverUrl}/api/v1/`), "trailing slash was added");
|
||||||
mockGet.reset();
|
mockGet.resetHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// with slash
|
// with slash
|
||||||
|
|
@ -42,7 +42,7 @@ add_task(withMockApiServer(async function test_getApiUrlSlashes(serverUrl, prefe
|
||||||
const endpoint = await NormandyApi.getApiUrl("test-endpoint");
|
const endpoint = await NormandyApi.getApiUrl("test-endpoint");
|
||||||
equal(endpoint, `${serverUrl}/test/`);
|
equal(endpoint, `${serverUrl}/test/`);
|
||||||
ok(mockGet.calledWithExactly(`${serverUrl}/api/v1/`), "existing trailing slash was preserved");
|
ok(mockGet.calledWithExactly(`${serverUrl}/api/v1/`), "existing trailing slash was preserved");
|
||||||
mockGet.reset();
|
mockGet.resetHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
NormandyApi.clearIndexCache();
|
NormandyApi.clearIndexCache();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue