Skip to content

Commit c00e6cf

Browse files
committed
Backed out changeset b4f503076020 (bug 1745819) for causing mochitest failures on test_ext_scripting_contentScripts.html. CLOSED TREE
1 parent d9d0b0a commit c00e6cf

12 files changed

+64
-214
lines changed

dom/chrome-webidl/WebExtensionContentScript.webidl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ interface MozDocumentMatcher {
2020
*/
2121
boolean matchesURI(URI uri);
2222

23+
/**
24+
* Returns true if the the given URI and LoadInfo objects match.
25+
* This should be used to determine whether to begin pre-loading a content
26+
* script based on network events.
27+
*/
28+
boolean matchesLoadInfo(URI uri, LoadInfo loadInfo);
29+
2330
/**
2431
* Returns true if the given window matches. This should be used
2532
* to determine whether to run a script in a window at load time.
@@ -32,14 +39,6 @@ interface MozDocumentMatcher {
3239
[Constant]
3340
readonly attribute boolean allFrames;
3441

35-
/**
36-
* If we can't check extension has permissions to access the URI upfront,
37-
* set the flag to perform the origin check at runtime, upon matching.
38-
* This is always true in MV3, where host permissions are optional.
39-
*/
40-
[Constant]
41-
readonly attribute boolean checkPermissions;
42-
4342
/**
4443
* If true, this (misleadingly-named, but inherited from Chrome) attribute
4544
* causes us to match frames with URLs which inherit a principal that
@@ -103,8 +102,6 @@ interface MozDocumentMatcher {
103102
dictionary MozDocumentMatcherInit {
104103
boolean allFrames = false;
105104

106-
boolean checkPermissions = false;
107-
108105
sequence<OriginAttributesPatternDictionary>? originAttributesPatterns = null;
109106

110107
boolean matchAboutBlank = false;

toolkit/components/extensions/WebExtensionContentScript.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ class MozDocumentMatcher : public nsISupports, public nsWrapperCache {
115115
bool Matches(const DocInfo& aDoc) const;
116116
bool MatchesURI(const URLInfo& aURL) const;
117117

118+
bool MatchesLoadInfo(const URLInfo& aURL, nsILoadInfo* aLoadInfo) const {
119+
return Matches({aURL, aLoadInfo});
120+
}
121+
118122
bool MatchesWindowGlobal(dom::WindowGlobalChild& aWindow) const;
119123

120124
WebExtensionPolicy* GetExtension() { return mExtension; }
@@ -123,7 +127,6 @@ class MozDocumentMatcher : public nsISupports, public nsWrapperCache {
123127
const WebExtensionPolicy* Extension() const { return mExtension; }
124128

125129
bool AllFrames() const { return mAllFrames; }
126-
bool CheckPermissions() const { return mCheckPermissions; }
127130
bool MatchAboutBlank() const { return mMatchAboutBlank; }
128131

129132
MatchPatternSet* Matches() { return mMatches; }
@@ -170,7 +173,6 @@ class MozDocumentMatcher : public nsISupports, public nsWrapperCache {
170173
Nullable<MatchGlobSet> mExcludeGlobs;
171174

172175
bool mAllFrames;
173-
bool mCheckPermissions;
174176
Nullable<uint64_t> mFrameID;
175177
bool mMatchAboutBlank;
176178
Nullable<dom::Sequence<OriginAttributesPattern>> mOriginAttributesPatterns;

toolkit/components/extensions/WebExtensionPolicy.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,6 @@ MozDocumentMatcher::MozDocumentMatcher(GlobalObject& aGlobal,
634634
: mHasActiveTabPermission(aInit.mHasActiveTabPermission),
635635
mRestricted(aRestricted),
636636
mAllFrames(aInit.mAllFrames),
637-
mCheckPermissions(aInit.mCheckPermissions),
638637
mFrameID(aInit.mFrameID),
639638
mMatchAboutBlank(aInit.mMatchAboutBlank) {
640639
MatchPatternOptions options;
@@ -691,11 +690,6 @@ WebExtensionContentScript::WebExtensionContentScript(
691690
mCssPaths.Assign(aInit.mCssPaths);
692691
mJsPaths.Assign(aInit.mJsPaths);
693692
mExtension = &aExtension;
694-
695-
// Origin permissions are optional in mv3, so always check them at runtime.
696-
if (mExtension->ManifestVersion() >= 3) {
697-
mCheckPermissions = true;
698-
}
699693
}
700694

701695
bool MozDocumentMatcher::Matches(const DocInfo& aDoc) const {
@@ -744,7 +738,7 @@ bool MozDocumentMatcher::Matches(const DocInfo& aDoc) const {
744738
return true;
745739
}
746740

747-
if (mRestricted && mExtension && mExtension->IsRestrictedDoc(aDoc)) {
741+
if (mRestricted && mExtension->IsRestrictedDoc(aDoc)) {
748742
return false;
749743
}
750744

@@ -758,8 +752,6 @@ bool MozDocumentMatcher::Matches(const DocInfo& aDoc) const {
758752
}
759753

760754
bool MozDocumentMatcher::MatchesURI(const URLInfo& aURL) const {
761-
MOZ_ASSERT(!mRestricted && !mCheckPermissions || mExtension);
762-
763755
if (!mMatches->Matches(aURL)) {
764756
return false;
765757
}
@@ -780,11 +772,6 @@ bool MozDocumentMatcher::MatchesURI(const URLInfo& aURL) const {
780772
return false;
781773
}
782774

783-
if (mCheckPermissions &&
784-
!mExtension->CanAccessURI(aURL, false, false, true)) {
785-
return false;
786-
}
787-
788775
return true;
789776
}
790777

toolkit/components/extensions/test/mochitest/test_ext_scripting_contentScripts.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@
3030
// Used in `file_contains_iframe.html`
3131
"*://example.org/",
3232
],
33-
granted_host_permissions: true,
3433
...manifestProps,
3534
},
36-
temporarilyInstalled: true,
3735
...otherProps,
3836
});
3937
};

0 commit comments

Comments
 (0)