forked from mozilla/multi-account-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wildcard subdomains - e.g. *.google.com
- Loading branch information
Showing
6 changed files
with
258 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const {initializeWithTab} = require("../common"); | ||
|
||
describe("Wildcard Subdomains Feature", function () { | ||
const url1 = "http://www.example.com"; | ||
const url2 = "http://zzz.example.com"; | ||
const wildcardHostname = "example.com"; | ||
|
||
beforeEach(async function () { | ||
this.webExt = await initializeWithTab({ | ||
cookieStoreId: "firefox-container-4", | ||
url: url1 | ||
}); | ||
await this.webExt.popup.helper.clickElementById("always-open-in"); | ||
await this.webExt.popup.helper.clickElementByQuerySelectorAll("#picker-identities-list > .menu-item"); | ||
}); | ||
|
||
afterEach(function () { | ||
this.webExt.destroy(); | ||
}); | ||
|
||
describe("open new Tab with different subdomain in the default container", function () { | ||
beforeEach(async function () { | ||
// new Tab opening url2 in default container | ||
await this.webExt.background.browser.tabs._create({ | ||
cookieStoreId: "firefox-default", | ||
url: url2 | ||
}, { | ||
options: { | ||
webRequestError: true // because request is canceled due to reopening | ||
} | ||
}); | ||
}); | ||
|
||
it("should not open the confirm page", async function () { | ||
this.webExt.background.browser.tabs.create.should.not.have.been.called; | ||
}); | ||
|
||
it("should not remove the new Tab that got opened in the default container", function () { | ||
this.webExt.background.browser.tabs.remove.should.not.have.been.called; | ||
}); | ||
}); | ||
|
||
describe("set wildcard hostname and then open new Tab with different subdomain in the default container", function () { | ||
let newTab; | ||
beforeEach(async function () { | ||
// Set wildcard | ||
await this.webExt.background.window.assignManager._setWildcardHostnameForAssignment(url1, wildcardHostname); | ||
|
||
// new Tab opening url2 in default container | ||
newTab = await this.webExt.background.browser.tabs._create({ | ||
cookieStoreId: "firefox-default", | ||
url: url2 | ||
}, { | ||
options: { | ||
webRequestError: true // because request is canceled due to reopening | ||
} | ||
}); | ||
}); | ||
|
||
it("should open the confirm page", async function () { | ||
this.webExt.background.browser.tabs.create.should.have.been.calledWithMatch({ | ||
url: "moz-extension://fake/confirm-page.html?" + | ||
`url=${encodeURIComponent(url2)}` + | ||
`&cookieStoreId=${this.webExt.tab.cookieStoreId}`, | ||
cookieStoreId: undefined, | ||
openerTabId: null, | ||
index: 2, | ||
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); | ||
}); | ||
}); | ||
}); |