Commit 978b9698 authored by Noemi Erli's avatar Noemi Erli
Browse files

Backed out 2 changesets (bug 1529762) for failures in browser_page_style.js CLOSED TREE

Backed out changeset f49189976e12 (bug 1529762)
Backed out changeset 459979fd1d25 (bug 1529762)
parent e4906acd
......@@ -15,14 +15,12 @@ class PageStyleChild extends ActorChild {
sendStyleSheetInfo(mm) {
let content = mm.content;
content.requestIdleCallback(() => {
let filteredStyleSheets = this._filterStyleSheets(this.getAllStyleSheets(content), content);
let filteredStyleSheets = this._filterStyleSheets(this.getAllStyleSheets(content), content);
mm.sendAsyncMessage("PageStyle:StyleSheets", {
filteredStyleSheets,
authorStyleDisabled: this.getViewer(content).authorStyleDisabled,
preferredStyleSheetSet: content.document.preferredStyleSheetSet,
});
mm.sendAsyncMessage("PageStyle:StyleSheets", {
filteredStyleSheets,
authorStyleDisabled: this.getViewer(content).authorStyleDisabled,
preferredStyleSheetSet: content.document.preferredStyleSheetSet,
});
}
......
......@@ -6505,9 +6505,7 @@ var gPageStyleMenu = {
init() {
let mm = window.messageManager;
mm.addMessageListener("PageStyle:StyleSheets", (msg) => {
if (msg.target.permanentKey) {
this._pageStyleSheets.set(msg.target.permanentKey, msg.data);
}
this._pageStyleSheets.set(msg.target.permanentKey, msg.data);
});
},
......
"use strict";
/**
* Stylesheets are updated for a browser after the pageshow event.
* This helper function returns a Promise that waits for that pageshow
* event, and then resolves on the next tick to ensure that gPageStyleMenu
* has had a chance to update the stylesheets.
*
* @param browser
* The <xul:browser> to wait for.
* @return Promise
*/
function promiseStylesheetsUpdated(browser) {
return ContentTask.spawn(browser, { PAGE }, async function(args) {
return new Promise((resolve) => {
addEventListener("pageshow", function onPageShow(e) {
if (e.target.location == args.PAGE) {
removeEventListener("pageshow", onPageShow);
content.setTimeout(resolve, 0);
}
});
});
});
}
const PAGE = "http://example.com/browser/browser/base/content/test/general/page_style_sample.html";
/*
......
......@@ -2,6 +2,29 @@
const PAGE = "http://example.com/browser/browser/base/content/test/general/page_style_sample.html";
/**
* Stylesheets are updated for a browser after the pageshow event.
* This helper function returns a Promise that waits for that pageshow
* event, and then resolves on the next tick to ensure that gPageStyleMenu
* has had a chance to update the stylesheets.
*
* @param browser
* The <xul:browser> to wait for.
* @return Promise
*/
function promiseStylesheetsUpdated(browser) {
return ContentTask.spawn(browser, { PAGE }, async function(args) {
return new Promise((resolve) => {
addEventListener("pageshow", function onPageShow(e) {
if (e.target.location == args.PAGE) {
removeEventListener("pageshow", onPageShow);
content.setTimeout(resolve, 0);
}
});
});
});
}
/**
* Tests that the Page Style menu shows the currently
* selected Page Style after a new one has been selected.
......@@ -26,8 +49,13 @@ add_task(async function() {
target.click();
// Now we need to wait for the content process to send its stylesheet
// update for the selected tab to the parent.
await promiseStylesheetsUpdated(browser);
// update for the selected tab to the parent. Because messages are
// guaranteed to be sent in order, we'll make sure we do the check
// after the parent has been updated by yielding until the child
// has finished running a ContentTask for us.
await ContentTask.spawn(browser, {}, async function() {
dump("\nJust wasting some time.\n");
});
gPageStyleMenu.fillPopup(menupopup);
// gPageStyleMenu empties out the menu between opens, so we need
......
......@@ -510,18 +510,3 @@ function getCertExceptionDialog(aLocation) {
}
return undefined;
}
/**
* Waits for the message from content to update the Page Style menu.
*
* @param browser
* The <xul:browser> to wait for.
* @return Promise
*/
async function promiseStylesheetsUpdated(browser) {
await BrowserTestUtils.waitForMessage(browser.messageManager,
"PageStyle:StyleSheets");
// Resolve on the next tick of the event loop to give the Page Style
// menu code an opportunity to update.
await new Promise(resolve => Services.tm.dispatchToMainThread(resolve));
}
......@@ -46,6 +46,7 @@ const whitelist = {
"resource:///actors/BrowserTabChild.jsm",
"resource:///modules/ContentMetaHandler.jsm",
"resource:///actors/LinkHandlerChild.jsm",
"resource:///actors/PageStyleChild.jsm",
"resource:///actors/SearchTelemetryChild.jsm",
"resource://gre/modules/ActorChild.jsm",
"resource://gre/modules/ActorManagerChild.jsm",
......
......@@ -215,9 +215,6 @@ let ACTORS = {
"PageStyle:Switch",
"PageStyle:Disable",
],
// Only matching web pages, as opposed to internal about:, chrome: or
// resource: pages. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns
matches: ["*://*/*"],
},
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment