Bug 1562292: Part 1b.1 - Fix FindWithSpecialName with inaccessible "_parent". r=nika
authorKris Maglione <maglione.k@gmail.com>
Thu, 01 Aug 2019 18:45:47 -0700
changeset 488061 f1fc2382346d163fe18a8fe5d323aafa759e1317
parent 488060 d513683e1fdbfdb79f5112e9745f2fc0fb4e92fe
child 488062 a8ac7bcafc270b5be3eca84efebcde672fe8fba5
push id36435
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:46:49 +0000
treeherdermozilla-central@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1562292
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562292: Part 1b.1 - Fix FindWithSpecialName with inaccessible "_parent". r=nika The special name "_parent" resolves to the parent window when one exists, or the current target window if it does not. Either way, it returns null if the target is inaccessible. The current logic, however, treats inaccessible the same as nonexistent, and returns the current window if it is has a parent from which it is sandboxed. This differs from the corresponding DocShell logic, which returns null in that case. This patch aligns the BrowsingContext behavior with the DocShell behavior. Differential Revision: https://phabricator.services.mozilla.com/D40493
docshell/base/BrowsingContext.cpp
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -545,19 +545,20 @@ BrowsingContext* BrowsingContext::FindWi
   // TODO(farre): Neither BrowsingContext nor nsDocShell checks if the
   // browsing context pointed to by a special name is active. Should
   // it be? See Bug 1527913.
   if (aName.LowerCaseEqualsLiteral("_self")) {
     return this;
   }
 
   if (aName.LowerCaseEqualsLiteral("_parent")) {
-    return mParent && aRequestingContext.CanAccess(mParent.get())
-               ? mParent.get()
-               : this;
+    if (mParent) {
+      return aRequestingContext.CanAccess(mParent) ? mParent.get() : nullptr;
+    }
+    return this;
   }
 
   if (aName.LowerCaseEqualsLiteral("_top")) {
     BrowsingContext* top = Top();
 
     return aRequestingContext.CanAccess(top) ? top : nullptr;
   }