Skip to content

Commit 9d40574

Browse files
committed
Bug 1085214 - Implement location.ancestorOrigins r=necko-reviewers,webidl,dom-core,smaug,jesup,zcorpan
This implements this attribute on Location and also adheres to the changes to the spec introduced in whatwg/html#11560 Tentative tests are also added in this patch. Differential Revision: https://phabricator.services.mozilla.com/D273393 UltraBlame original commit: 626bfdb90f3e1a0f78c6a6e832697520396e66bf
1 parent e182244 commit 9d40574

25 files changed

+5535
-347
lines changed

docshell/base/CanonicalBrowsingContext.cpp

Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,13 @@ h
481481
#
482482
include
483483
"
484+
nsScriptSecurityManager
485+
.
486+
h
487+
"
488+
#
489+
include
490+
"
484491
nsSecureBrowserUI
485492
.
486493
h
@@ -19980,6 +19987,311 @@ ReconstructContiguousEntryList
1998019987
;
1998119988
}
1998219989
}
19990+
void
19991+
CanonicalBrowsingContext
19992+
:
19993+
:
19994+
CreateRedactedAncestorOriginsList
19995+
(
19996+
nsIPrincipal
19997+
*
19998+
aThisDocumentPrincipal
19999+
)
20000+
{
20001+
MOZ_DIAGNOSTIC_ASSERT
20002+
(
20003+
aThisDocumentPrincipal
20004+
)
20005+
;
20006+
nsTArray
20007+
<
20008+
nsCOMPtr
20009+
<
20010+
nsIPrincipal
20011+
>
20012+
>
20013+
ancestorPrincipals
20014+
;
20015+
CanonicalBrowsingContext
20016+
*
20017+
parent
20018+
=
20019+
GetParent
20020+
(
20021+
)
20022+
;
20023+
if
20024+
(
20025+
!
20026+
parent
20027+
)
20028+
{
20029+
mPossiblyRedactedAncestorOriginsList
20030+
=
20031+
std
20032+
:
20033+
:
20034+
move
20035+
(
20036+
ancestorPrincipals
20037+
)
20038+
;
20039+
return
20040+
;
20041+
}
20042+
MOZ_DIAGNOSTIC_ASSERT
20043+
(
20044+
!
20045+
parent
20046+
-
20047+
>
20048+
IsChrome
20049+
(
20050+
)
20051+
)
20052+
;
20053+
const
20054+
Span
20055+
<
20056+
const
20057+
nsCOMPtr
20058+
<
20059+
nsIPrincipal
20060+
>
20061+
>
20062+
parentAncestorOriginsList
20063+
=
20064+
parent
20065+
-
20066+
>
20067+
GetPossiblyRedactedAncestorOriginsList
20068+
(
20069+
)
20070+
;
20071+
WindowGlobalParent
20072+
*
20073+
ancestorWGP
20074+
=
20075+
GetParentWindowContext
20076+
(
20077+
)
20078+
;
20079+
auto
20080+
referrerPolicy
20081+
=
20082+
GetEmbedderFrameReferrerPolicy
20083+
(
20084+
)
20085+
;
20086+
bool
20087+
masked
20088+
=
20089+
false
20090+
;
20091+
if
20092+
(
20093+
referrerPolicy
20094+
=
20095+
=
20096+
ReferrerPolicy
20097+
:
20098+
:
20099+
No_referrer
20100+
)
20101+
{
20102+
masked
20103+
=
20104+
true
20105+
;
20106+
}
20107+
else
20108+
if
20109+
(
20110+
referrerPolicy
20111+
=
20112+
=
20113+
ReferrerPolicy
20114+
:
20115+
:
20116+
Same_origin
20117+
&
20118+
&
20119+
!
20120+
ancestorWGP
20121+
-
20122+
>
20123+
DocumentPrincipal
20124+
(
20125+
)
20126+
-
20127+
>
20128+
Equals
20129+
(
20130+
aThisDocumentPrincipal
20131+
)
20132+
)
20133+
{
20134+
masked
20135+
=
20136+
true
20137+
;
20138+
}
20139+
if
20140+
(
20141+
masked
20142+
)
20143+
{
20144+
ancestorPrincipals
20145+
.
20146+
AppendElement
20147+
(
20148+
nullptr
20149+
)
20150+
;
20151+
}
20152+
else
20153+
{
20154+
auto
20155+
*
20156+
principal
20157+
=
20158+
ancestorWGP
20159+
-
20160+
>
20161+
DocumentPrincipal
20162+
(
20163+
)
20164+
;
20165+
ancestorPrincipals
20166+
.
20167+
AppendElement
20168+
(
20169+
principal
20170+
-
20171+
>
20172+
GetIsNullPrincipal
20173+
(
20174+
)
20175+
?
20176+
nullptr
20177+
:
20178+
principal
20179+
)
20180+
;
20181+
}
20182+
for
20183+
(
20184+
const
20185+
auto
20186+
&
20187+
ancestorOrigin
20188+
:
20189+
parentAncestorOriginsList
20190+
)
20191+
{
20192+
if
20193+
(
20194+
masked
20195+
&
20196+
&
20197+
ancestorOrigin
20198+
&
20199+
&
20200+
ancestorOrigin
20201+
-
20202+
>
20203+
Equals
20204+
(
20205+
ancestorWGP
20206+
-
20207+
>
20208+
DocumentPrincipal
20209+
(
20210+
)
20211+
)
20212+
)
20213+
{
20214+
ancestorPrincipals
20215+
.
20216+
AppendElement
20217+
(
20218+
nullptr
20219+
)
20220+
;
20221+
}
20222+
else
20223+
{
20224+
ancestorPrincipals
20225+
.
20226+
AppendElement
20227+
(
20228+
ancestorOrigin
20229+
)
20230+
;
20231+
masked
20232+
=
20233+
false
20234+
;
20235+
}
20236+
}
20237+
mPossiblyRedactedAncestorOriginsList
20238+
=
20239+
std
20240+
:
20241+
:
20242+
move
20243+
(
20244+
ancestorPrincipals
20245+
)
20246+
;
20247+
}
20248+
Span
20249+
<
20250+
const
20251+
nsCOMPtr
20252+
<
20253+
nsIPrincipal
20254+
>
20255+
>
20256+
CanonicalBrowsingContext
20257+
:
20258+
:
20259+
GetPossiblyRedactedAncestorOriginsList
20260+
(
20261+
)
20262+
const
20263+
{
20264+
return
20265+
mPossiblyRedactedAncestorOriginsList
20266+
;
20267+
}
20268+
void
20269+
CanonicalBrowsingContext
20270+
:
20271+
:
20272+
SetPossiblyRedactedAncestorOriginsList
20273+
(
20274+
nsTArray
20275+
<
20276+
nsCOMPtr
20277+
<
20278+
nsIPrincipal
20279+
>
20280+
>
20281+
aAncestorOriginsList
20282+
)
20283+
{
20284+
mPossiblyRedactedAncestorOriginsList
20285+
=
20286+
std
20287+
:
20288+
:
20289+
move
20290+
(
20291+
aAncestorOriginsList
20292+
)
20293+
;
20294+
}
1998320295
EntryList
1998420296
*
1998520297
CanonicalBrowsingContext

0 commit comments

Comments
 (0)