Skip to content

Commit

Permalink
Backed out 16 changesets (bug 1770944) as req by asuth.
Browse files Browse the repository at this point in the history
Backed out changeset 61af32f40777 (bug 1770944)
Backed out changeset 4ff0c45db93b (bug 1770944)
Backed out changeset 8a217eff7bcd (bug 1770944)
Backed out changeset 6435f48c96bf (bug 1770944)
Backed out changeset 0d2432765ca0 (bug 1770944)
Backed out changeset 58e02566db85 (bug 1770944)
Backed out changeset 0a8c4c2460ee (bug 1770944)
Backed out changeset 9416bafd9982 (bug 1770944)
Backed out changeset 79de4f83fe2e (bug 1770944)
Backed out changeset 63ac518aceb0 (bug 1770944)
Backed out changeset 14952f872b77 (bug 1770944)
Backed out changeset f65e0967ad75 (bug 1770944)
Backed out changeset bd53c42038f7 (bug 1770944)
Backed out changeset 36c378ba8212 (bug 1770944)
Backed out changeset 9ba54ab06348 (bug 1770944)
Backed out changeset fb5a54b3cbe9 (bug 1770944)
  • Loading branch information
nbeleuzu committed Feb 23, 2024
1 parent 57c8f70 commit 7eae8c1
Show file tree
Hide file tree
Showing 99 changed files with 3,020 additions and 273 deletions.
17 changes: 17 additions & 0 deletions browser/actors/ContextMenuChild.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,17 @@ export class ContextMenuChild extends JSWindowActorChild {
return this.contentWindow.HTMLTextAreaElement.isInstance(node);
}

/**
* Check if we are in the parent process and the current iframe is the RDM iframe.
*/
_isTargetRDMFrame(node) {
return (
Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_DEFAULT &&
node.tagName === "iframe" &&
node.hasAttribute("mozbrowser")
);
}

_isSpellCheckEnabled(aNode) {
// We can always force-enable spellchecking on textboxes
if (this._isTargetATextBox(aNode)) {
Expand Down Expand Up @@ -534,6 +545,12 @@ export class ContextMenuChild extends JSWindowActorChild {
return;
}

if (this._isTargetRDMFrame(aEvent.composedTarget)) {
// The target is in the DevTools RDM iframe, a proper context menu event
// will be created from the RDM browser.
return;
}

let doc = aEvent.composedTarget.ownerDocument;
let {
mozDocumentURIIfNotForErrorPages: docLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ add_task(async function checkAllTheFiles() {
// Wait for all manifest to be parsed
await PerfTestHelpers.throttledMapPromises(manifestURIs, parseManifest);

for (let jsm of Components.manager.getComponentJSMs()) {
gReferencesFromCode.set(jsm, null);
}
for (let esModule of Components.manager.getComponentESModules()) {
gReferencesFromCode.set(esModule, null);
}
Expand Down
1 change: 1 addition & 0 deletions build/non-unified-compat
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dom/base/
dom/battery/
dom/bindings/
dom/broadcastchannel/
dom/browser-element/
dom/cache/
dom/canvas/
dom/clients/
Expand Down
7 changes: 7 additions & 0 deletions caps/BasePrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,13 @@ BasePrincipal::GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) {
return NS_OK;
}

NS_IMETHODIMP
BasePrincipal::GetIsInIsolatedMozBrowserElement(
bool* aIsInIsolatedMozBrowserElement) {
*aIsInIsolatedMozBrowserElement = IsInIsolatedMozBrowserElement();
return NS_OK;
}

nsresult BasePrincipal::GetAddonPolicy(
extensions::WebExtensionPolicy** aResult) {
AssertIsOnMainThread();
Expand Down
5 changes: 5 additions & 0 deletions caps/BasePrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ class BasePrincipal : public nsJSPrincipals {
NS_IMETHOD GetIsIpAddress(bool* aIsIpAddress) override;
NS_IMETHOD GetIsLocalIpAddress(bool* aIsIpAddress) override;
NS_IMETHOD GetIsOnion(bool* aIsOnion) override;
NS_IMETHOD GetIsInIsolatedMozBrowserElement(
bool* aIsInIsolatedMozBrowserElement) final;
NS_IMETHOD GetUserContextId(uint32_t* aUserContextId) final;
NS_IMETHOD GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) final;
NS_IMETHOD GetSiteOrigin(nsACString& aSiteOrigin) final;
Expand Down Expand Up @@ -248,6 +250,9 @@ class BasePrincipal : public nsJSPrincipals {
uint32_t PrivateBrowsingId() const {
return mOriginAttributes.mPrivateBrowsingId;
}
bool IsInIsolatedMozBrowserElement() const {
return mOriginAttributes.mInIsolatedMozBrowser;
}

PrincipalKind Kind() const { return mKind; }

Expand Down
5 changes: 5 additions & 0 deletions caps/OriginAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ void OriginAttributes::CreateSuffix(nsACString& aStr) const {
// naming.
//

if (mInIsolatedMozBrowser) {
params.Set(u"inBrowser"_ns, u"1"_ns);
}

if (mUserContextId != nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) {
value.Truncate();
value.AppendInt(mUserContextId);
Expand Down Expand Up @@ -331,6 +335,7 @@ bool OriginAttributes::PopulateFromSuffix(const nsACString& aStr) {
return false;
}

mInIsolatedMozBrowser = true;
return true;
}

Expand Down
18 changes: 17 additions & 1 deletion caps/OriginAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
public:
OriginAttributes() = default;

explicit OriginAttributes(bool aInIsolatedMozBrowser) {
mInIsolatedMozBrowser = aInIsolatedMozBrowser;
}

explicit OriginAttributes(const OriginAttributesDictionary& aOther)
: OriginAttributesDictionary(aOther) {}

Expand Down Expand Up @@ -70,7 +74,8 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
}

[[nodiscard]] bool EqualsIgnoringFPD(const OriginAttributes& aOther) const {
return mUserContextId == aOther.mUserContextId &&
return mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
mUserContextId == aOther.mUserContextId &&
mPrivateBrowsingId == aOther.mPrivateBrowsingId &&
mGeckoViewSessionContextId == aOther.mGeckoViewSessionContextId;
}
Expand Down Expand Up @@ -154,6 +159,11 @@ class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary {

// Performs a match of |aAttrs| against this pattern.
bool Matches(const OriginAttributes& aAttrs) const {
if (mInIsolatedMozBrowser.WasPassed() &&
mInIsolatedMozBrowser.Value() != aAttrs.mInIsolatedMozBrowser) {
return false;
}

if (mUserContextId.WasPassed() &&
mUserContextId.Value() != aAttrs.mUserContextId) {
return false;
Expand Down Expand Up @@ -217,6 +227,12 @@ class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary {
}

bool Overlaps(const OriginAttributesPattern& aOther) const {
if (mInIsolatedMozBrowser.WasPassed() &&
aOther.mInIsolatedMozBrowser.WasPassed() &&
mInIsolatedMozBrowser.Value() != aOther.mInIsolatedMozBrowser.Value()) {
return false;
}

if (mUserContextId.WasPassed() && aOther.mUserContextId.WasPassed() &&
mUserContextId.Value() != aOther.mUserContextId.Value()) {
return false;
Expand Down
11 changes: 11 additions & 0 deletions caps/nsIPrincipal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,17 @@ interface nsIPrincipal : nsISupports
*/
[infallible] readonly attribute unsigned long privateBrowsingId;

/**
* Returns true iff the principal is inside an isolated mozbrowser element.
* <xul:browser> is not considered to be a mozbrowser element.
* <iframe mozbrowser noisolation> does not count as isolated since
* isolation is disabled. Isolation can only be disabled if the
* containing document is chrome.
*
* May be called from any thread.
*/
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;

/**
* Returns true iff this is a null principal (corresponding to an
* unknown, hence assumed minimally privileged, security context).
Expand Down
6 changes: 6 additions & 0 deletions caps/tests/gtest/TestOriginAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ TEST(OriginAttributes, Suffix_default)
TestSuffix(attrs);
}

TEST(OriginAttributes, Suffix_inIsolatedMozBrowser)
{
OriginAttributes attrs(true);
TestSuffix(attrs);
}

TEST(OriginAttributes, FirstPartyDomain_default)
{
bool oldFpiPref = Preferences::GetBool(FPI_PREF);
Expand Down
33 changes: 33 additions & 0 deletions caps/tests/unit/test_origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ function checkCrossOrigin(a, b) {

function checkOriginAttributes(prin, attrs, suffix) {
attrs = attrs || {};
Assert.equal(
prin.originAttributes.inIsolatedMozBrowser,
attrs.inIsolatedMozBrowser || false
);
Assert.equal(prin.originSuffix, suffix || "");
Assert.equal(ChromeUtils.originAttributesToSuffix(attrs), suffix || "");
Assert.ok(
Expand Down Expand Up @@ -55,6 +59,9 @@ function printAttrs(name, attrs) {
"\tuserContextId: " +
attrs.userContextId +
",\n" +
"\tinIsolatedMozBrowser: " +
attrs.inIsolatedMozBrowser +
",\n" +
"\tprivateBrowsingId: '" +
attrs.privateBrowsingId +
"',\n" +
Expand All @@ -69,6 +76,10 @@ function checkValues(attrs, values) {
// printAttrs("attrs", attrs);
// printAttrs("values", values);
Assert.equal(attrs.userContextId, values.userContextId || 0);
Assert.equal(
attrs.inIsolatedMozBrowser,
values.inIsolatedMozBrowser || false
);
Assert.equal(attrs.privateBrowsingId, values.privateBrowsingId || "");
Assert.equal(attrs.firstPartyDomain, values.firstPartyDomain || "");
}
Expand Down Expand Up @@ -130,6 +141,26 @@ function run_test() {
// Test origin attributes.
//

// Just browser.
var exampleOrg_browser = ssm.createContentPrincipal(
makeURI("http://example.org"),
{ inIsolatedMozBrowser: true }
);
var nullPrin_browser = ssm.createNullPrincipal({
inIsolatedMozBrowser: true,
});
checkOriginAttributes(
exampleOrg_browser,
{ inIsolatedMozBrowser: true },
"^inBrowser=1"
);
checkOriginAttributes(
nullPrin_browser,
{ inIsolatedMozBrowser: true },
"^inBrowser=1"
);
Assert.equal(exampleOrg_browser.origin, "http://example.org^inBrowser=1");

// First party Uri
var exampleOrg_firstPartyDomain = ssm.createContentPrincipal(
makeURI("http://example.org"),
Expand Down Expand Up @@ -175,6 +206,7 @@ function run_test() {
);

// Check that all of the above are cross-origin.
checkCrossOrigin(exampleOrg_browser, nullPrin_browser);
checkCrossOrigin(exampleOrg_firstPartyDomain, exampleOrg);
checkCrossOrigin(exampleOrg_userContext, exampleOrg);

Expand Down Expand Up @@ -213,6 +245,7 @@ function run_test() {
var tests = [
["", {}],
["^userContextId=3", { userContextId: 3 }],
["^inBrowser=1", { inIsolatedMozBrowser: true }],
["^firstPartyDomain=example.org", { firstPartyDomain: "example.org" }],
];

Expand Down
3 changes: 2 additions & 1 deletion dom/base/ChromeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class ChromeUtils {
static bool IsOriginAttributesEqualIgnoringFPD(
const dom::OriginAttributesDictionary& aA,
const dom::OriginAttributesDictionary& aB) {
return aA.mUserContextId == aB.mUserContextId &&
return aA.mInIsolatedMozBrowser == aB.mInIsolatedMozBrowser &&
aA.mUserContextId == aB.mUserContextId &&
aA.mPrivateBrowsingId == aB.mPrivateBrowsingId;
}

Expand Down
11 changes: 11 additions & 0 deletions dom/base/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class nsIDOMXULSelectControlElement;
class nsIDOMXULSelectControlItemElement;
class nsIFrame;
class nsIHTMLCollection;
class nsIMozBrowserFrame;
class nsIPrincipal;
class nsIScreen;
class nsIScrollableFrame;
Expand Down Expand Up @@ -457,6 +458,16 @@ class Element : public FragmentOrElement {
*/
virtual bool IsInteractiveHTMLContent() const;

/**
* Returns |this| as an nsIMozBrowserFrame* if the element is a frame or
* iframe element.
*
* We have this method, rather than using QI, so that we can use it during
* the servo traversal, where we can't QI DOM nodes because of non-thread-safe
* refcounts.
*/
virtual nsIMozBrowserFrame* GetAsMozBrowserFrame() { return nullptr; }

/**
* Is the attribute named aAttribute a mapped attribute?
*/
Expand Down
24 changes: 23 additions & 1 deletion dom/base/InProcessBrowserChildMessageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "nsFrameLoaderOwner.h"
#include "nsQueryObject.h"
#include "xpcpublic.h"
#include "nsIMozBrowserFrame.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/Document.h"
Expand Down Expand Up @@ -99,6 +100,15 @@ InProcessBrowserChildMessageManager::InProcessBrowserChildMessageManager(
mOwner(aOwner),
mChromeMessageManager(aChrome) {
mozilla::HoldJSObjects(this);

// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
// GetEventTargetParent implementation.
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwner);
if (browserFrame) {
mIsBrowserFrame = browserFrame->GetReallyIsBrowser();
} else {
mIsBrowserFrame = false;
}
}

InProcessBrowserChildMessageManager::~InProcessBrowserChildMessageManager() {
Expand Down Expand Up @@ -226,7 +236,19 @@ void InProcessBrowserChildMessageManager::GetEventTargetParent(
return;
}

aVisitor.SetParentTarget(mOwner, false);
if (mIsBrowserFrame &&
(!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
if (mOwner) {
if (nsPIDOMWindowInner* innerWindow =
mOwner->OwnerDoc()->GetInnerWindow()) {
// 'this' is already a "chrome handler", so we consider window's
// parent target to be part of that same part of the event path.
aVisitor.SetParentTarget(innerWindow->GetParentTarget(), false);
}
}
} else {
aVisitor.SetParentTarget(mOwner, false);
}
}

class nsAsyncScriptLoad : public Runnable {
Expand Down
3 changes: 3 additions & 0 deletions dom/base/InProcessBrowserChildMessageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class InProcessBrowserChildMessageManager final
RefPtr<nsDocShell> mDocShell;
bool mLoadingScript;

// Is this the message manager for an in-process <iframe mozbrowser>? This
// affects where events get sent, so it affects GetEventTargetParent.
bool mIsBrowserFrame;
bool mPreventEventsEscaping;

// We keep a strong reference to the frameloader after we've started
Expand Down
Loading

0 comments on commit 7eae8c1

Please sign in to comment.