Bug 947544 - Fix intermittent in the Shader Editor test browser_se_bfcache.js. r=vp

This commit is contained in:
Brandon Benvie 2014-01-08 09:24:39 -08:00
parent 79c6767d01
commit 67903d3205

View File

@ -10,19 +10,18 @@ function ifWebGLSupported() {
let { gFront, $, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
let reloaded = reload(target);
let firstProgram = yield once(gFront, "program-linked");
yield once(gFront, "program-linked");
yield reloaded;
let navigated = navigate(target, MULTIPLE_CONTEXTS_URL);
let [secondProgram, thirdProgram] = yield getPrograms(gFront, 2);
yield getPrograms(gFront, 2);
yield navigated;
let vsEditor = yield ShadersEditorsView._getEditor("vs");
let fsEditor = yield ShadersEditorsView._getEditor("fs");
yield navigateInHistory(target, "back", "will-navigate");
yield once(panel.panelWin, EVENTS.PROGRAMS_ADDED);
yield once(panel.panelWin, EVENTS.SOURCES_SHOWN);
yield waitForSources();
is($("#content").hidden, false,
"The tool's content should not be hidden.");
@ -37,8 +36,7 @@ function ifWebGLSupported() {
"The fragment shader editor contains the correct text.");
yield navigateInHistory(target, "forward", "will-navigate");
yield once(panel.panelWin, EVENTS.PROGRAMS_ADDED);
yield once(panel.panelWin, EVENTS.SOURCES_SHOWN);
yield waitForSources();
is($("#content").hidden, false,
"The tool's content should not be hidden.");
@ -54,4 +52,18 @@ function ifWebGLSupported() {
yield teardown(panel);
finish();
function waitForSources() {
let deferred = promise.defer();
let win = panel.panelWin;
// These events must fire in this in order and the second event fires
// synchronously after the first event, so we can't use Promise.all and the
// `once` helper.
win.once(win.EVENTS.PROGRAMS_ADDED, () => {
win.once(win.EVENTS.SOURCES_SHOWN, () => {
deferred.resolve();
});
});
return deferred.promise;
}
}