fixed mocha tests
This commit is contained in:
parent
db46e71516
commit
694b0f7b47
9 changed files with 81 additions and 66 deletions
|
@ -11,7 +11,7 @@ const messageHandler = {
|
||||||
|
|
||||||
switch (m.method) {
|
switch (m.method) {
|
||||||
case "getShortcuts":
|
case "getShortcuts":
|
||||||
console.log(identityState.keyboardShortcut);
|
console.log("getShortcuts", identityState.keyboardShortcut);
|
||||||
response = identityState.keyboardShortcut;
|
response = identityState.keyboardShortcut;
|
||||||
break;
|
break;
|
||||||
case "setShortcut":
|
case "setShortcut":
|
||||||
|
@ -91,7 +91,7 @@ const messageHandler = {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
console.log(response);
|
console.log(m.method, "response", response);
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ async function setupOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupContainerShortcutSelects () {
|
async function setupContainerShortcutSelects () {
|
||||||
const keyboardShortcut = browser.runtime.sendMessage({method: "getShortcuts"});
|
const keyboardShortcut = await browser.runtime.sendMessage({method: "getShortcuts"});
|
||||||
console.log(keyboardShortcut);
|
// console.log(keyboardShortcut);
|
||||||
const identities = await browser.contextualIdentities.query({});
|
const identities = await browser.contextualIdentities.query({});
|
||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
const noneOption = document.createElement("option");
|
const noneOption = document.createElement("option");
|
||||||
|
|
|
@ -984,7 +984,6 @@ Logic.registerPanel(REOPEN_IN_CONTAINER_PICKER, {
|
||||||
document.getElementById("picker-title").textContent = "Reopen This Site in";
|
document.getElementById("picker-title").textContent = "Reopen This Site in";
|
||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
const currentTab = await Utils.currentTab();
|
const currentTab = await Utils.currentTab();
|
||||||
console.log(currentTab);
|
|
||||||
const pickedFunction = function (identity) {
|
const pickedFunction = function (identity) {
|
||||||
const newUserContextId = Utils.userContextId(identity.cookieStoreId);
|
const newUserContextId = Utils.userContextId(identity.cookieStoreId);
|
||||||
Utils.reloadInContainer(
|
Utils.reloadInContainer(
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
"default_icon": "img/multiaccountcontainer-16.svg",
|
"default_icon": "img/multiaccountcontainer-16.svg",
|
||||||
"default_title": "Always open this in a Container",
|
"default_title": "Always open this in a Container",
|
||||||
"default_popup": "pageActionPopup.html",
|
"default_popup": "pageActionPopup.html",
|
||||||
"pinned": true,
|
"pinned": false,
|
||||||
"show_matches": ["*://*/*"]
|
"show_matches": ["*://*/*"]
|
||||||
},
|
},
|
||||||
"background": {
|
"background": {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const {initializeWithTab} = require("../common");
|
const {initializeWithTab} = require("../common");
|
||||||
|
|
||||||
describe("Assignment Feature", function () {
|
describe("Assignment Reopen Feature", function () {
|
||||||
const url = "http://example.com";
|
const url = "http://example.com";
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.webExt = await initializeWithTab({
|
this.webExt = await initializeWithTab({
|
||||||
cookieStoreId: "firefox-container-1",
|
cookieStoreId: "firefox-default",
|
||||||
url
|
url
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -17,61 +17,71 @@ describe("Assignment Feature", function () {
|
||||||
describe("click the 'Always open in' checkbox in the popup", function () {
|
describe("click the 'Always open in' checkbox in the popup", function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
// popup click to set assignment for activeTab.url
|
// popup click to set assignment for activeTab.url
|
||||||
await this.webExt.popup.helper.clickElementById("container-page-assigned");
|
await this.webExt.popup.helper.clickElementById("always-open-in");
|
||||||
|
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("open new Tab with the assigned URL in the default container", function () {
|
it("should open the page in the assigned container", async function () {
|
||||||
let newTab;
|
// should have created a new tab with the confirm page
|
||||||
beforeEach(async function () {
|
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
|
||||||
// new Tab opening activeTab.url in default container
|
active: true,
|
||||||
newTab = await this.webExt.background.browser.tabs._create({
|
cookieStoreId: "firefox-container-4",
|
||||||
cookieStoreId: "firefox-default",
|
index: 1,
|
||||||
url
|
openerTabId: null,
|
||||||
}, {
|
url: "http://example.com"
|
||||||
options: {
|
|
||||||
webRequestError: true // because request is canceled due to reopening
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should open the confirm page", async function () {
|
});
|
||||||
// should have created a new tab with the confirm page
|
|
||||||
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
|
});
|
||||||
url: "moz-extension://fake/confirm-page.html?" +
|
|
||||||
|
describe("Assignment Comfirm Page Feature", function () {
|
||||||
|
const url = "http://example.com";
|
||||||
|
|
||||||
|
beforeEach(async function () {
|
||||||
|
this.webExt = await initializeWithTab({
|
||||||
|
cookieStoreId: "firefox-container-4",
|
||||||
|
url
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
this.webExt.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("open new Tab with the assigned URL in the default container", function () {
|
||||||
|
let newTab;
|
||||||
|
beforeEach(async function () {
|
||||||
|
await this.webExt.popup.helper.clickElementById("always-open-in");
|
||||||
|
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
|
||||||
|
|
||||||
|
// new Tab opening activeTab.url in default container
|
||||||
|
newTab = await this.webExt.background.browser.tabs._create({
|
||||||
|
cookieStoreId: "firefox-default",
|
||||||
|
url
|
||||||
|
}, {
|
||||||
|
options: {
|
||||||
|
webRequestError: true // because request is canceled due to reopening
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should open the confirm page", async function () {
|
||||||
|
// should have created a new tab with the confirm page
|
||||||
|
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({
|
||||||
|
url: "moz-extension://fake/confirm-page.html?" +
|
||||||
`url=${encodeURIComponent(url)}` +
|
`url=${encodeURIComponent(url)}` +
|
||||||
`&cookieStoreId=${this.webExt.tab.cookieStoreId}`,
|
`&cookieStoreId=${this.webExt.tab.cookieStoreId}`,
|
||||||
cookieStoreId: undefined,
|
cookieStoreId: undefined,
|
||||||
openerTabId: null,
|
openerTabId: null,
|
||||||
index: 2,
|
index: 2,
|
||||||
active: true
|
active: true
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should remove the new Tab that got opened in the default container", function () {
|
|
||||||
this.webExt.background.browser.tabs.remove.should.have.been.calledWith(newTab.id);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("click the 'Always open in' checkbox in the popup again", function () {
|
it("should remove the new Tab that got opened in the default container", function () {
|
||||||
beforeEach(async function () {
|
this.webExt.background.browser.tabs.remove.should.have.been.calledWith(newTab.id);
|
||||||
// popup click to remove assignment for activeTab.url
|
|
||||||
await this.webExt.popup.helper.clickElementById("container-page-assigned");
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("open new Tab with the no longer assigned URL in the default container", function () {
|
|
||||||
beforeEach(async function () {
|
|
||||||
// new Tab opening activeTab.url in default container
|
|
||||||
await this.webExt.background.browser.tabs._create({
|
|
||||||
cookieStoreId: "firefox-default",
|
|
||||||
url
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should not open the confirm page", async function () {
|
|
||||||
// should not have created a new tab
|
|
||||||
this.webExt.background.browser.tabs.create.should.not.have.been.called;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,8 +11,9 @@ describe("Containers Management", function () {
|
||||||
|
|
||||||
describe("creating a new container", function () {
|
describe("creating a new container", function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
await this.webExt.popup.helper.clickElementById("container-add-link");
|
await this.webExt.popup.helper.clickElementById("manage-containers-link");
|
||||||
await this.webExt.popup.helper.clickElementById("edit-container-ok-link");
|
await this.webExt.popup.helper.clickElementById("new-container");
|
||||||
|
await this.webExt.popup.helper.clickElementById("create-container-ok-link");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create it in the browser as well", function () {
|
it("should create it in the browser as well", function () {
|
||||||
|
@ -21,8 +22,9 @@ describe("Containers Management", function () {
|
||||||
|
|
||||||
describe("removing it afterwards", function () {
|
describe("removing it afterwards", function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
await this.webExt.popup.helper.clickElementById("edit-containers-link");
|
await this.webExt.popup.helper.clickElementById("manage-containers-link");
|
||||||
await this.webExt.popup.helper.clickElementByQuerySelectorAll(".delete-container-icon", "last");
|
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item", "last");
|
||||||
|
await this.webExt.popup.helper.clickElementById("delete-container-button");
|
||||||
await this.webExt.popup.helper.clickElementById("delete-container-ok-link");
|
await this.webExt.popup.helper.clickElementById("delete-container-ok-link");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@ describe("External Webextensions", function () {
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
this.webExt = await initializeWithTab({
|
this.webExt = await initializeWithTab({
|
||||||
cookieStoreId: "firefox-container-1",
|
cookieStoreId: "firefox-container-4",
|
||||||
url
|
url
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.webExt.popup.helper.clickElementById("container-page-assigned");
|
await this.webExt.popup.helper.clickElementById("always-open-in");
|
||||||
|
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item", "last");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -32,7 +33,7 @@ describe("External Webextensions", function () {
|
||||||
|
|
||||||
const [promise] = this.webExt.background.browser.runtime.onMessageExternal.addListener.yield(message, sender);
|
const [promise] = this.webExt.background.browser.runtime.onMessageExternal.addListener.yield(message, sender);
|
||||||
const answer = await promise;
|
const answer = await promise;
|
||||||
expect(answer.userContextId === "1").to.be.true;
|
expect(answer.userContextId === "4").to.be.true;
|
||||||
expect(answer.neverAsk === false).to.be.true;
|
expect(answer.neverAsk === false).to.be.true;
|
||||||
expect(
|
expect(
|
||||||
Object.prototype.hasOwnProperty.call(
|
Object.prototype.hasOwnProperty.call(
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe("Sync", function() {
|
||||||
delete this.syncHelper;
|
delete this.syncHelper;
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only("testIdentityStateCleanup", async function() {
|
it("testIdentityStateCleanup", async function() {
|
||||||
await this.syncHelper.stopSyncListeners();
|
await this.syncHelper.stopSyncListeners();
|
||||||
|
|
||||||
await this.syncHelper.setState({}, LOCAL_DATA, TEST_CONTAINERS, []);
|
await this.syncHelper.setState({}, LOCAL_DATA, TEST_CONTAINERS, []);
|
||||||
|
|
|
@ -4,11 +4,12 @@ describe("#940", function () {
|
||||||
describe("when other onBeforeRequestHandlers are faster and redirect with the same requestId", function () {
|
describe("when other onBeforeRequestHandlers are faster and redirect with the same requestId", function () {
|
||||||
it("should not open two confirm pages", async function () {
|
it("should not open two confirm pages", async function () {
|
||||||
const webExtension = await initializeWithTab({
|
const webExtension = await initializeWithTab({
|
||||||
cookieStoreId: "firefox-container-1",
|
cookieStoreId: "firefox-container-4",
|
||||||
url: "http://example.com"
|
url: "http://example.com"
|
||||||
});
|
});
|
||||||
|
|
||||||
await webExtension.popup.helper.clickElementById("container-page-assigned");
|
await webExtension.popup.helper.clickElementById("always-open-in");
|
||||||
|
await webExtension.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
|
||||||
|
|
||||||
const responses = {};
|
const responses = {};
|
||||||
await webExtension.background.browser.tabs._create({
|
await webExtension.background.browser.tabs._create({
|
||||||
|
@ -36,10 +37,12 @@ describe("#940", function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
|
|
||||||
this.webExt = await initializeWithTab({
|
this.webExt = await initializeWithTab({
|
||||||
cookieStoreId: "firefox-container-1",
|
cookieStoreId: "firefox-container-4",
|
||||||
url: "https://www.youtube.com"
|
url: "https://www.youtube.com"
|
||||||
});
|
});
|
||||||
await this.webExt.popup.helper.clickElementById("container-page-assigned");
|
|
||||||
|
await this.webExt.popup.helper.clickElementById("always-open-in");
|
||||||
|
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item");
|
||||||
|
|
||||||
global.clock = sinon.useFakeTimers();
|
global.clock = sinon.useFakeTimers();
|
||||||
this.redirectedRequest = async (options = {}) => {
|
this.redirectedRequest = async (options = {}) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue