Backed out changeset e29230160e7b (bug 1753352) for causing wpt failures, a=backout

This commit is contained in:
Dianna Smith 2024-09-10 22:18:04 -04:00
parent de9889b410
commit 12faf49780
13 changed files with 37 additions and 53 deletions

View File

@ -97,7 +97,7 @@ nsresult ContentPrincipal::GenerateOriginNoSuffixFromURI(
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(!NS_IsAboutBlankAllowQueryAndFragment(origin),
MOZ_ASSERT(!NS_IsAboutBlank(origin),
"The inner URI for about:blank must be moz-safe-about:blank");
// Handle non-strict file:// uris.

View File

@ -2804,7 +2804,7 @@ bool CanonicalBrowsingContext::AllowedInBFCache(
nsCOMPtr<nsIURI> currentURI = wgp->GetDocumentURI();
// Exempt about:* pages from bfcache, with the exception of about:blank
if (currentURI->SchemeIs("about") &&
!NS_IsAboutBlankAllowQueryAndFragment(currentURI)) {
!currentURI->GetSpecOrDefault().EqualsLiteral("about:blank")) {
bfcacheCombo |= BFCacheStatus::ABOUT_PAGE;
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug, (" * about:* page"));
}

View File

@ -10164,7 +10164,7 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
bool nsDocShell::IsAboutBlankLoadOntoInitialAboutBlank(
nsIURI* aURI, bool aInheritPrincipal, nsIPrincipal* aPrincipalToInherit) {
return NS_IsAboutBlankAllowQueryAndFragment(aURI) && aInheritPrincipal &&
return NS_IsAboutBlank(aURI) && aInheritPrincipal &&
(aPrincipalToInherit == GetInheritedPrincipal(false)) &&
(!mContentViewer || !mContentViewer->GetDocument() ||
mContentViewer->GetDocument()->IsInitialDocument());

View File

@ -7282,8 +7282,7 @@ bool nsContentUtils::ChannelShouldInheritPrincipal(
// we're checking for things that will use the owner.
inherit =
(NS_SUCCEEDED(URIInheritsSecurityContext(aURI, &uriInherits)) &&
(uriInherits || (aInheritForAboutBlank &&
NS_IsAboutBlankAllowQueryAndFragment(aURI)))) ||
(uriInherits || (aInheritForAboutBlank && NS_IsAboutBlank(aURI)))) ||
//
// file: uri special-casing
//

View File

@ -1848,9 +1848,12 @@ nsresult nsGlobalWindowInner::EnsureClientSource() {
bool ignoreLoadInfo = false;
// Note, this is mostly copied from NS_IsAboutBlank(). Its duplicated
// here so we can efficiently check about:srcdoc as well.
if (uri->SchemeIs("about")) {
ignoreLoadInfo =
NS_IsAboutBlankAllowQueryAndFragment(uri) || NS_IsAboutSrcdoc(uri);
nsCString spec = uri->GetSpecOrDefault();
ignoreLoadInfo = spec.EqualsLiteral("about:blank") ||
spec.EqualsLiteral("about:srcdoc");
} else {
// Its not an about: URL, so now check for our other URL types.
ignoreLoadInfo = uri->SchemeIs("data") || uri->SchemeIs("blob");

View File

@ -21,7 +21,6 @@
#include "mozilla/StorageAccess.h"
#include "nsIGlobalObject.h"
#include "nsString.h"
#include "nsReadableUtils.h"
namespace mozilla::dom {
@ -215,9 +214,7 @@ already_AddRefed<Promise> Clients::OpenWindow(const nsAString& aURL,
return outerPromise.forget();
}
if (aURL.EqualsLiteral(u"about:blank") ||
StringBeginsWith(aURL, u"about:blank?"_ns) ||
StringBeginsWith(aURL, u"about:blank#"_ns)) {
if (aURL.EqualsLiteral("about:blank")) {
CopyableErrorResult rv;
rv.ThrowTypeError(
"Passing \"about:blank\" to Clients.openWindow is not allowed");

View File

@ -224,7 +224,7 @@ RefPtr<ClientOpPromise> ClientNavigateOpChild::DoNavigate(
return ClientOpPromise::CreateAndReject(result, __func__);
}
if (NS_IsAboutBlankAllowQueryAndFragment(url)) {
if (url->GetSpecOrDefault().EqualsLiteral("about:blank")) {
CopyableErrorResult result;
result.ThrowTypeError("Navigation to \"about:blank\" is not allowed");
return ClientOpPromise::CreateAndReject(result, __func__);

View File

@ -338,8 +338,12 @@ nsresult nsHTMLDocument::StartDocumentLoad(
// mDocumentURI hasn't been set, yet, so get the URI from the channel
nsCOMPtr<nsIURI> uri;
aChannel->GetOriginalURI(getter_AddRefs(uri));
if (NS_IsAboutBlankAllowQueryAndFragment(uri)) {
loadAsHtml5 = false;
// Adapted from nsDocShell:
// GetSpec can be expensive for some URIs, so check the scheme first.
if (uri && uri->SchemeIs("about")) {
if (uri->GetSpecOrDefault().EqualsLiteral("about:blank")) {
loadAsHtml5 = false;
}
}
}

View File

@ -23,7 +23,6 @@
#include "mozilla/StoragePrincipalHelper.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/Telemetry.h"
#include "nsAboutProtocolUtils.h"
#include "nsBufferedStreams.h"
#include "nsCategoryCache.h"
#include "nsComponentManagerUtils.h"
@ -2762,20 +2761,6 @@ bool NS_IsAboutBlank(nsIURI* uri) {
return spec.EqualsLiteral("about:blank");
}
bool NS_IsAboutBlankAllowQueryAndFragment(nsIURI* uri) {
// GetSpec can be expensive for some URIs, so check the scheme first.
if (!uri->SchemeIs("about")) {
return false;
}
nsAutoCString name;
if (NS_FAILED(NS_GetAboutModuleName(uri, name))) {
return false;
}
return name.EqualsLiteral("blank");
}
bool NS_IsAboutSrcdoc(nsIURI* uri) {
// GetSpec can be expensive for some URIs, so check the scheme first.
if (!uri->SchemeIs("about")) {

View File

@ -857,12 +857,6 @@ void net_EnsurePSMInit();
*/
bool NS_IsAboutBlank(nsIURI* uri);
/**
* Test whether a URI is "about:blank", possibly with fragment or query. |uri|
* must not be null
*/
bool NS_IsAboutBlankAllowQueryAndFragment(nsIURI* uri);
/**
* Test whether a URI is "about:srcdoc". |uri| must not be null
*/

View File

@ -239,8 +239,6 @@ class nsParser final : public nsIParser,
void HandleParserContinueEvent(class nsParserContinueEvent*);
void Reset() {
MOZ_ASSERT(!mIsAboutBlank,
"Only the XML fragment parsing case is supposed to call this.");
Cleanup();
mUnusedInput.Truncate();
Initialize();

View File

@ -2,19 +2,19 @@
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[load & pageshow event do not fire on contentWindow of <iframe> element created with no src]
expected: [FAIL, PASS]
expected:
if (os == "win") and swgl: [FAIL, PASS]
if os == "linux": [FAIL, PASS]
FAIL
[load & pageshow events do not fire on contentWindow of <iframe> element created with src='']
expected: [FAIL, PASS]
expected:
if os == "linux": [FAIL, PASS]
FAIL
[load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank']
expected: [FAIL, PASS]
[load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank#foo']
expected: [FAIL, PASS]
[load & pageshow events do not fire on contentWindow of <iframe> element created with src='about:blank?foo']
expected: [FAIL, PASS]
[load event does not fire on window.open('about:blank?foo')]
expected: [FAIL, PASS]
expected:
if (os == "linux") and debug and not fission and swgl: [FAIL, PASS]
if (os == "linux") and debug and fission: [FAIL, PASS]
if (os == "linux") and not debug: [FAIL, PASS]
FAIL

View File

@ -1,6 +1,10 @@
[load-pageshow-events-window-open.html]
[load event does not fire on window.open('about:blank')]
expected: [FAIL, PASS]
[load event does not fire on window.open('about:blank?foo')]
expected: [FAIL, PASS]
expected:
if (os == "linux") and not swgl and fission and not debug and (processor == "x86"): [FAIL, PASS]
if (os == "linux") and not swgl and fission and not debug and (processor == "x86_64"): [FAIL, PASS]
if (os == "linux") and not swgl and fission and debug: [FAIL, PASS]
if (os == "linux") and swgl and not fission: [FAIL, PASS]
if os == "win": FAIL
if os == "mac": FAIL
[PASS, FAIL]