Bug 1608545 - ensure userContextId inherited from relatedTab is used throughout addTab and test for it, r=dao

Differential Revision: https://phabricator.services.mozilla.com/D60017

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2020-01-16 13:54:21 +00:00
Родитель 0700c14b2d
Коммит 9d4ffbfc01
2 изменённых файлов: 26 добавлений и 8 удалений

Просмотреть файл

@ -2634,12 +2634,17 @@
this.tabContainer.getAttribute("overflow") != "true" &&
this.animationsEnabled;
// Related tab inherits current tab's user context unless a different
// usercontextid is specified
if (userContextId == null && openerTab) {
userContextId = openerTab.getAttribute("usercontextid") || 0;
}
this.setTabAttributes(t, {
animate,
noInitialLabel,
aURI,
userContextId,
openerTab,
skipBackgroundNotify,
pinned,
skipAnimation,
@ -3111,7 +3116,6 @@
noInitialLabel,
aURI,
userContextId,
openerTab,
skipBackgroundNotify,
pinned,
skipAnimation,
@ -3126,12 +3130,6 @@
}
}
// Related tab inherits current tab's user context unless a different
// usercontextid is specified
if (userContextId == null && openerTab) {
userContextId = openerTab.getAttribute("usercontextid") || 0;
}
if (userContextId) {
tab.setAttribute("usercontextid", userContextId);
ContextualIdentityService.setTabStyle(tab);

Просмотреть файл

@ -23,6 +23,11 @@ add_task(async function() {
1,
"Related tab (relatedToCurrent) inherits current tab's usercontextid"
);
is(
relatedTab.linkedBrowser.contentPrincipal.userContextId,
1,
"Related tab's browser actually inherits the current tab's usercontextid"
);
BrowserTestUtils.removeTab(relatedTab);
gBrowser.selectedTab = tab;
@ -35,6 +40,11 @@ add_task(async function() {
2,
"Related tab (relatedToCurrent) with overridden usercontextid"
);
is(
relatedTab.linkedBrowser.contentPrincipal.userContextId,
2,
"Related tab's browser actually gets overridden usercontextid"
);
BrowserTestUtils.removeTab(relatedTab);
gBrowser.selectedTab = tab;
@ -51,6 +61,11 @@ add_task(async function() {
1,
"Related tab (referrer) inherits current tab's usercontextid"
);
is(
relatedTab.linkedBrowser.contentPrincipal.userContextId,
1,
"Related tab's browser (referrer) actually inherits the current tab's usercontextid"
);
BrowserTestUtils.removeTab(relatedTab);
gBrowser.selectedTab = tab;
@ -68,6 +83,11 @@ add_task(async function() {
2,
"Related tab (referrer) with overridden usercontextid"
);
is(
relatedTab.linkedBrowser.contentPrincipal.userContextId,
2,
"Related tab's browser (referrer) actually gets overridden usercontextid"
);
BrowserTestUtils.removeTab(relatedTab);
BrowserTestUtils.removeTab(tab);