mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1161701 - Listen for AboutReader:Ready notification instead of waiting for content to appear in testReaderView. r=mfinkle
This commit is contained in:
parent
2dce534c6e
commit
551057a991
@ -25,20 +25,13 @@ function promiseBrowserEvent(browser, eventType) {
|
||||
});
|
||||
}
|
||||
|
||||
function promiseWaitForCondition(win, condition) {
|
||||
function promiseNotification(topic) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var tries = 0;
|
||||
var interval = win.setInterval(function() {
|
||||
if (tries >= 30) {
|
||||
do_print("Condition didn't pass. Moving on.");
|
||||
moveOn();
|
||||
}
|
||||
if (condition()) {
|
||||
moveOn();
|
||||
}
|
||||
tries++;
|
||||
}, 200);
|
||||
var moveOn = function() { win.clearInterval(interval); resolve(); };
|
||||
function observe(subject, topic, data) {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
resolve();
|
||||
}
|
||||
Services.obs.addObserver(observe, topic, false);
|
||||
});
|
||||
}
|
||||
|
||||
@ -60,7 +53,7 @@ add_task(function* test_reader_view_visibility() {
|
||||
|
||||
// We need to wait for reader content to appear because AboutReader.jsm
|
||||
// asynchronously fetches the content after about:reader loads.
|
||||
yield promiseWaitForCondition(gWin, () => title.textContent);
|
||||
yield promiseNotification("AboutReader:Ready");
|
||||
do_check_eq(title.textContent, "Article title");
|
||||
});
|
||||
|
||||
|
@ -791,6 +791,8 @@ AboutReader.prototype = {
|
||||
this._showListIntro();
|
||||
this._requestFavicon();
|
||||
this._doc.body.classList.add("loaded");
|
||||
|
||||
Services.obs.notifyObservers(null, "AboutReader:Ready", "");
|
||||
},
|
||||
|
||||
_hideContent: function Reader_hideContent() {
|
||||
|
Loading…
Reference in New Issue
Block a user