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