Backed out changeset 1bfa83880712 (bug 1662839) for browser_disable_author_style_oop.js failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2020-09-24 05:55:25 +03:00
parent 702f0bf062
commit d88ac68590
12 changed files with 18 additions and 135 deletions

View File

@ -38,17 +38,11 @@ class PageStyleChild extends JSWindowActorChild {
switch (msg.name) {
// Sent when the page's enabled style sheet is changed.
case "PageStyle:Switch":
if (this.browsingContext.top == this.browsingContext) {
this.browsingContext.authorStyleDisabledDefault = false;
}
this.docShell.contentViewer.authorStyleDisabled = false;
this._switchStylesheet(msg.data.title);
break;
// Sent when "No Style" is chosen.
case "PageStyle:Disable":
if (this.browsingContext.top == this.browsingContext) {
this.browsingContext.authorStyleDisabledDefault = true;
}
this.docShell.contentViewer.authorStyleDisabled = true;
break;
}

View File

@ -1,5 +0,0 @@
"use strict";
module.exports = {
extends: ["plugin:mozilla/browser-test", "plugin:mozilla/mochitest-test"],
};

View File

@ -1,4 +0,0 @@
[browser_disable_author_style_oop.js]
support-files =
page_style.html

View File

@ -1,65 +0,0 @@
"use strict";
async function getColor(aSpawnTarget) {
return SpecialPowers.spawn(aSpawnTarget, [], function() {
return content.document.defaultView.getComputedStyle(
content.document.querySelector("p")
).color;
});
}
async function insertIFrame() {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
return new Promise(function(resolve) {
let e = content.document.createElement("iframe");
e.src =
"http://mochi.test:8888/browser/browser/base/content/test/pageStyle/page_style.html";
e.onload = () => resolve();
content.document.body.append(e);
});
});
}
// Test that inserting an iframe with a URL that is loaded OOP with Fission
// enabled correctly matches the tab's author style disabled state.
add_task(async function test_disable_style() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"http://example.com/browser/browser/base/content/test/pageStyle/page_style.html",
/* waitForLoad = */ true
);
let bc = gBrowser.selectedBrowser.browsingContext;
await insertIFrame();
is(
await getColor(bc),
"rgb(0, 0, 255)",
"parent color before disabling style"
);
is(
await getColor(bc.children[0]),
"rgb(0, 0, 255)",
"first child color before disabling style"
);
gPageStyleMenu.disableStyle();
is(await getColor(bc), "rgb(0, 0, 0)", "parent color after disabling style");
is(
await getColor(bc.children[0]),
"rgb(0, 0, 0)",
"first child color after disabling style"
);
await insertIFrame();
is(
await getColor(bc.children[1]),
"rgb(0, 0, 0)",
"second child color after disabling style"
);
BrowserTestUtils.removeTab(tab);
});

View File

@ -1,8 +0,0 @@
<!DOCTYPE html>
<style>
p { color: blue; font-weight: bold; }
</style>
<p>Some text.</p>
<script>
let gFramesLoaded = 0;
</script>

View File

@ -35,7 +35,6 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/outOfProcess/browser.ini',
'content/test/pageActions/browser.ini',
'content/test/pageinfo/browser.ini',
'content/test/pageStyle/browser.ini',
'content/test/performance/browser.ini',
'content/test/performance/hidpi/browser.ini',
'content/test/performance/io/browser.ini',

View File

@ -2501,19 +2501,6 @@ void BrowsingContext::DidSet(FieldIndex<IDX_AncestorLoading>) {
}
}
void BrowsingContext::DidSet(FieldIndex<IDX_AuthorStyleDisabledDefault>) {
MOZ_ASSERT(IsTop(),
"Should only set AuthorStyleDisabledDefault in the top "
"browsing context");
// We don't need to handle changes to this field, since PageStyleChild.jsm
// will respond to the PageStyle:Disable message in all content processes.
//
// But we store the state here on the top BrowsingContext so that the
// docshell has somewhere to look for the current author style disabling
// state when new iframes are inserted.
}
void BrowsingContext::DidSet(FieldIndex<IDX_TextZoom>, float aOldValue) {
if (GetTextZoom() == aOldValue) {
return;

View File

@ -157,12 +157,7 @@ class WindowProxyHolder;
FIELD(IsSingleToplevelInHistory, bool) \
FIELD(UseErrorPages, bool) \
FIELD(PlatformOverride, nsString) \
FIELD(HasLoadedNonInitialDocument, bool) \
FIELD(CreatedDynamically, bool) \
/* Default value for nsIContentViewer::authorStyleDisabled in any new \
* browsing contexts created as a descendant of this one. Valid only for \
* top BCs. */ \
FIELD(AuthorStyleDisabledDefault, bool)
FIELD(HasLoadedNonInitialDocument, bool)
// BrowsingContext, in this context, is the cross process replicated
// environment in which information about documents is stored. In
@ -446,10 +441,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
float FullZoom() const { return GetFullZoom(); }
float TextZoom() const { return GetTextZoom(); }
bool AuthorStyleDisabledDefault() const {
return GetAuthorStyleDisabledDefault();
}
bool UseGlobalHistory() const { return GetUseGlobalHistory(); }
uint64_t BrowserId() const { return GetBrowserId(); }
@ -889,7 +880,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
void DidSet(FieldIndex<IDX_FullZoom>, float aOldValue);
void DidSet(FieldIndex<IDX_TextZoom>, float aOldValue);
void DidSet(FieldIndex<IDX_AuthorStyleDisabledDefault>);
// True if the process attemping to set field is the same as the owning
// process.

View File

@ -7274,8 +7274,10 @@ nsresult nsDocShell::RestoreFromHistory() {
nsCOMPtr<nsIContentViewer> newCv(viewer);
float overrideDPPX = 0.0f;
if (oldCv) {
bool styleDisabled = false;
if (oldCv && newCv) {
oldCv->GetOverrideDPPX(&overrideDPPX);
oldCv->GetAuthorStyleDisabled(&styleDisabled);
}
// Protect against mLSHE going away via a load triggered from
@ -7500,15 +7502,11 @@ nsresult nsDocShell::RestoreFromHistory() {
FavorPerformanceHint(true);
}
if (oldCv) {
if (oldCv && newCv) {
newCv->SetOverrideDPPX(overrideDPPX);
newCv->SetAuthorStyleDisabled(styleDisabled);
}
// Take the author style disabled state from the top browsing context.
// (PageStyleChild.jsm ensures this is up to date.)
bool styleDisabled = GetBrowsingContext()->Top()->AuthorStyleDisabledDefault();
newCv->SetAuthorStyleDisabled(styleDisabled);
if (document) {
RefPtr<nsDocShell> parent = GetInProcessParentDocshell();
if (parent) {
@ -8074,6 +8072,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
const Encoding* hintCharset = nullptr;
int32_t hintCharsetSource = kCharsetUninitialized;
float overrideDPPX = 1.0;
bool styleDisabled = false;
// |newMUDV| also serves as a flag to set the data from the above vars
nsCOMPtr<nsIContentViewer> newCv;
@ -8107,6 +8106,8 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldCv->GetOverrideDPPX(&overrideDPPX),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(oldCv->GetAuthorStyleDisabled(&styleDisabled),
NS_ERROR_FAILURE);
}
}
}
@ -8164,13 +8165,10 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
NS_ENSURE_SUCCESS(newCv->SetHintCharacterSetSource(hintCharsetSource),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(newCv->SetOverrideDPPX(overrideDPPX), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(newCv->SetAuthorStyleDisabled(styleDisabled),
NS_ERROR_FAILURE);
}
// Take the author style disabled state from the top browsing context.
// (PageStyleChild.jsm ensures this is up to date.)
bool styleDisabled = GetBrowsingContext()->Top()->AuthorStyleDisabledDefault();
mContentViewer->SetAuthorStyleDisabled(styleDisabled);
// Stuff the bgcolor from the old pres shell into the new
// pres shell. This improves page load continuity.
if (RefPtr<PresShell> presShell = mContentViewer->GetPresShell()) {

View File

@ -272,10 +272,7 @@ interface nsIContentViewer : nsISupports
*/
attribute float overrideDPPX;
/**
* Disable entire author style level (including HTML presentation hints),
* for this viewer but not any child viewers.
*/
/** Disable entire author style level (including HTML presentation hints) */
attribute boolean authorStyleDisabled;
/**

View File

@ -98,12 +98,6 @@ interface BrowsingContext {
[SetterThrows] attribute float textZoom;
// Default value for nsIContentViewer::authorStyleDisabled in any new
// browsing contexts created as a descendant of this one.
//
// Valid only for top browsing contexts.
[SetterThrows] attribute boolean authorStyleDisabledDefault;
/**
* Whether this docshell should save entries in global history.
*/

View File

@ -2636,6 +2636,12 @@ nsDocumentViewer::SetAuthorStyleDisabled(bool aStyleDisabled) {
if (mPresShell) {
mPresShell->SetAuthorStyleDisabled(aStyleDisabled);
}
auto children = [aStyleDisabled](nsDocumentViewer* aChild) {
aChild->SetAuthorStyleDisabled(aStyleDisabled);
};
CallChildren(children);
return NS_OK;
}