Backed out changeset 09d8e3caf51d (bug 1190663) for intermittent mochitest failures on Windows

MozReview-Commit-ID: BsHw1BxNF2t
This commit is contained in:
Kris Maglione 2016-03-02 19:50:22 -08:00
Родитель 67341496bf
Коммит 301a3bd87e
4 изменённых файлов: 22 добавлений и 104 удалений

Просмотреть файл

@ -125,19 +125,6 @@ global.makeWidgetId = id => {
return id.replace(/[^a-z0-9_-]/g, "_");
};
function promisePopupShown(popup) {
return new Promise(resolve => {
if (popup.state == "open") {
resolve();
} else {
popup.addEventListener("popupshown", function onPopupShown(event) {
popup.removeEventListener("popupshown", onPopupShown);
resolve();
});
}
});
}
class BasePopup {
constructor(extension, viewNode, popupURL) {
let popupURI = Services.io.newURI(popupURL, null, extension.baseURI);
@ -267,10 +254,6 @@ class BasePopup {
// Resizes the browser to match the preferred size of the content.
resizeBrowser() {
if (!this.browser) {
return;
}
let width, height;
try {
let w = {}, h = {};
@ -327,12 +310,7 @@ global.PanelPopup = class PanelPopup extends BasePopup {
}
closePopup() {
promisePopupShown(this.viewNode).then(() => {
// Make sure we're not already destroyed.
if (this.viewNode) {
this.viewNode.hidePopup();
}
});
this.viewNode.hidePopup();
}
};

Просмотреть файл

@ -3,8 +3,6 @@
"use strict";
function* testInArea(area) {
let scriptPage = url => `<html><head><meta charset="utf-8"><script src="${url}"></script></head></html>`;
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"background": {
@ -16,22 +14,17 @@ function* testInArea(area) {
},
files: {
"popup-a.html": scriptPage("popup-a.js"),
"popup-a.html": `<script src="popup-a.js"></script>`,
"popup-a.js": function() {
browser.runtime.sendMessage("from-popup-a");
browser.runtime.onMessage.addListener(msg => {
if (msg == "close-popup") {
window.close();
}
});
},
"data/popup-b.html": scriptPage("popup-b.js"),
"data/popup-b.html": `<script src="popup-b.js"></script>`,
"data/popup-b.js": function() {
browser.runtime.sendMessage("from-popup-b");
},
"data/background.html": scriptPage("background.js"),
"data/background.html": `<script src="background.js"></script>`,
"data/background.js": function() {
let sendClick;
@ -58,37 +51,26 @@ function* testInArea(area) {
},
() => {
browser.browserAction.setPopup({popup: "/popup-a.html"});
sendClick({expectEvent: false, expectPopup: "a", runNextTest: true});
},
() => {
browser.test.sendMessage("next-test", {expectClosed: true});
browser.runtime.sendMessage("close-popup");
sendClick({expectEvent: false, expectPopup: "a"});
},
];
let expect = {};
sendClick = ({expectEvent, expectPopup, runNextTest}) => {
expect = {event: expectEvent, popup: expectPopup, runNextTest};
sendClick = ({expectEvent, expectPopup}) => {
expect = {event: expectEvent, popup: expectPopup};
browser.test.sendMessage("send-click");
};
browser.runtime.onMessage.addListener(msg => {
if (msg == "close-popup") {
return;
} else if (expect.popup) {
if (expect.popup) {
browser.test.assertEq(msg, `from-popup-${expect.popup}`,
"expected popup opened");
} else {
browser.test.fail(`unexpected popup: ${msg}`);
browser.test.fail("unexpected popup");
}
expect.popup = null;
if (expect.runNextTest) {
expect.runNextTest = false;
tests.shift()();
} else {
browser.test.sendMessage("next-test");
}
browser.test.sendMessage("next-test");
});
browser.browserAction.onClicked.addListener(() => {
@ -125,20 +107,13 @@ function* testInArea(area) {
});
let widget;
extension.onMessage("next-test", Task.async(function* (expecting = {}) {
extension.onMessage("next-test", Task.async(function* () {
if (!widget) {
widget = getBrowserActionWidget(extension);
CustomizableUI.addWidgetToArea(widget.id, area);
}
if (expecting.expectClosed) {
let panel = getBrowserActionPopup(extension);
ok(panel, "Expect panel to exist");
yield promisePopupShown(panel);
yield promisePopupHidden(panel);
ok(true, "Panel is closed");
} else {
yield closeBrowserAction(extension);
}
yield closeBrowserAction(extension);
extension.sendMessage("next-test");
}));

Просмотреть файл

@ -19,11 +19,6 @@ add_task(function* testPageActionPopup() {
"popup-a.html": scriptPage("popup-a.js"),
"popup-a.js": function() {
browser.runtime.sendMessage("from-popup-a");
browser.runtime.onMessage.addListener(msg => {
if (msg == "close-popup") {
window.close();
}
});
},
"data/popup-b.html": scriptPage("popup-b.js"),
@ -60,37 +55,26 @@ add_task(function* testPageActionPopup() {
},
() => {
browser.pageAction.setPopup({tabId, popup: "/popup-a.html"});
sendClick({expectEvent: false, expectPopup: "a", runNextTest: true});
},
() => {
browser.test.sendMessage("next-test", {expectClosed: true});
browser.runtime.sendMessage("close-popup");
sendClick({expectEvent: false, expectPopup: "a"});
},
];
let expect = {};
sendClick = ({expectEvent, expectPopup, runNextTest}) => {
expect = {event: expectEvent, popup: expectPopup, runNextTest};
sendClick = ({expectEvent, expectPopup}) => {
expect = {event: expectEvent, popup: expectPopup};
browser.test.sendMessage("send-click");
};
browser.runtime.onMessage.addListener(msg => {
if (msg == "close-popup") {
return;
} else if (expect.popup) {
if (expect.popup) {
browser.test.assertEq(msg, `from-popup-${expect.popup}`,
"expected popup opened");
} else {
browser.test.fail(`unexpected popup: ${msg}`);
browser.test.fail("unexpected popup");
}
expect.popup = null;
if (expect.runNextTest) {
expect.runNextTest = false;
tests.shift()();
} else {
browser.test.sendMessage("next-test");
}
browser.test.sendMessage("next-test");
});
browser.pageAction.onClicked.addListener(() => {
@ -134,19 +118,12 @@ add_task(function* testPageActionPopup() {
clickPageAction(extension);
});
extension.onMessage("next-test", Task.async(function* (expecting = {}) {
extension.onMessage("next-test", Task.async(function* () {
let panel = document.getElementById(panelId);
if (expecting.expectClosed) {
ok(panel, "Expect panel to exist");
yield promisePopupShown(panel);
yield promisePopupHidden(panel);
ok(true, `Panel is closed`);
} else if (panel) {
if (panel) {
yield promisePopupShown(panel);
panel.hidePopup();
}
if (panel) {
panel = document.getElementById(panelId);
is(panel, null, "panel successfully removed from document after hiding");
}

Просмотреть файл

@ -7,7 +7,7 @@
* clickBrowserAction clickPageAction
* getBrowserActionPopup getPageActionPopup
* closeBrowserAction closePageAction
* promisePopupShown promisePopupHidden
* promisePopupShown
*/
var {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm");
@ -59,16 +59,6 @@ function promisePopupShown(popup) {
});
}
function promisePopupHidden(popup) {
return new Promise(resolve => {
let onPopupHidden = event => {
popup.removeEventListener("popuphidden", onPopupHidden);
resolve();
};
popup.addEventListener("popuphidden", onPopupHidden);
});
}
function getBrowserActionWidget(extension) {
return CustomizableUI.getWidget(makeWidgetId(extension.id) + "-browser-action");
}
@ -78,8 +68,6 @@ function getBrowserActionPopup(extension, win = window) {
if (group.areaType == CustomizableUI.TYPE_TOOLBAR) {
return win.document.getElementById("customizationui-widget-panel");
} else {
return win.PanelUI.panel;
}
return null;
}