Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions: Do not display HTTP/HTTPS URL schemes for unique hosts #8768

Merged
merged 4 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/scripts/controllers/permissions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ export class PermissionsController {
...metadata,
lastUpdated: Date.now(),
}

if (!newMetadataState[origin].extensionId && !newMetadataState[origin].host) {
newMetadataState[origin].host = new URL(origin).host
}

this._pendingSiteMetadata.add(origin)
this._setDomainMetadata(newMetadataState)
}
Expand Down
30 changes: 15 additions & 15 deletions test/unit/app/controllers/permissions/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ export const getNotifyAllDomains = (notifications = {}) => (notification) => {
* - e.g. permissions, caveats, and permission requests
*/

const ORIGINS = {
a: 'foo.xyz',
b: 'bar.abc',
c: 'baz.def',
const DOMAINS = {
a: { origin: 'https://foo.xyz', host: 'foo.xyz' },
b: { origin: 'https://bar.abc', host: 'bar.abc' },
c: { origin: 'https://baz.def', host: 'baz.def' },
}

const PERM_NAMES = {
Expand Down Expand Up @@ -630,7 +630,7 @@ export const constants = deepFreeze({
c: '3',
},

ORIGINS: { ...ORIGINS },
DOMAINS: { ...DOMAINS },

ACCOUNTS: { ...ACCOUNTS },

Expand All @@ -648,7 +648,7 @@ export const constants = deepFreeze({

case1: [
{
[ORIGINS.a]: {
[DOMAINS.a.origin]: {
[PERM_NAMES.eth_accounts]: {
lastApproved: 1,
accounts: {
Expand All @@ -660,7 +660,7 @@ export const constants = deepFreeze({
},
},
{
[ORIGINS.a]: {
[DOMAINS.a.origin]: {
[PERM_NAMES.eth_accounts]: {
lastApproved: 2,
accounts: {
Expand All @@ -675,7 +675,7 @@ export const constants = deepFreeze({

case2: [
{
[ORIGINS.a]: {
[DOMAINS.a.origin]: {
[PERM_NAMES.eth_accounts]: {
lastApproved: 1,
accounts: {},
Expand All @@ -686,18 +686,18 @@ export const constants = deepFreeze({

case3: [
{
[ORIGINS.a]: {
[DOMAINS.a.origin]: {
[PERM_NAMES.test_method]: { lastApproved: 1 },
},
[ORIGINS.b]: {
[DOMAINS.b.origin]: {
[PERM_NAMES.eth_accounts]: {
lastApproved: 1,
accounts: {
[ACCOUNTS.b.permitted[0]]: 1,
},
},
},
[ORIGINS.c]: {
[DOMAINS.c.origin]: {
[PERM_NAMES.test_method]: { lastApproved: 1 },
[PERM_NAMES.eth_accounts]: {
lastApproved: 1,
Expand All @@ -708,18 +708,18 @@ export const constants = deepFreeze({
},
},
{
[ORIGINS.a]: {
[DOMAINS.a.origin]: {
[PERM_NAMES.test_method]: { lastApproved: 2 },
},
[ORIGINS.b]: {
[DOMAINS.b.origin]: {
[PERM_NAMES.eth_accounts]: {
lastApproved: 1,
accounts: {
[ACCOUNTS.b.permitted[0]]: 1,
},
},
},
[ORIGINS.c]: {
[DOMAINS.c.origin]: {
[PERM_NAMES.test_method]: { lastApproved: 1 },
[PERM_NAMES.eth_accounts]: {
lastApproved: 2,
Expand All @@ -734,7 +734,7 @@ export const constants = deepFreeze({

case4: [
{
[ORIGINS.a]: {
[DOMAINS.a.origin]: {
[PERM_NAMES.test_method]: {
lastApproved: 1,
},
Expand Down
Loading