mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
[Australis] Backed out changesets 7c74e99d80c1 and 14e817fe25e1 (bug 956285) for mochitest-bc failures.
This commit is contained in:
parent
5ffde5cf9a
commit
3a50e45e8a
@ -544,14 +544,14 @@ var FullZoom = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronously broadcasts "browser-fullZoom:location-change" so that
|
||||
* listeners can be notified when the zoom levels on those pages change.
|
||||
* The notification is always asynchronous so that observers are guaranteed a
|
||||
* consistent behavior.
|
||||
* Asynchronously broadcasts "FullZoom:TESTS:location-change" so that tests
|
||||
* can select tabs, load pages, etc. and be notified when the zoom levels on
|
||||
* those pages change. The notification is always asynchronous so that
|
||||
* observers are guaranteed a consistent behavior.
|
||||
*/
|
||||
_notifyOnLocationChange: function FullZoom__notifyOnLocationChange() {
|
||||
this._executeSoon(function () {
|
||||
Services.obs.notifyObservers(null, "browser-fullZoom:location-change", "");
|
||||
Services.obs.notifyObservers(null, "FullZoom:TESTS:location-change", "");
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -317,7 +317,7 @@ let FullZoomHelper = {
|
||||
Services.obs.addObserver(function obs(subj, topic, data) {
|
||||
Services.obs.removeObserver(obs, topic);
|
||||
deferred.resolve();
|
||||
}, "browser-fullZoom:location-change", false);
|
||||
}, "FullZoom:TESTS:location-change", false);
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
|
@ -376,7 +376,6 @@ const CustomizableWidgets = [{
|
||||
// Register ourselves with the service so we know when the zoom prefs change.
|
||||
Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:zoomChange", false);
|
||||
Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:zoomReset", false);
|
||||
Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:location-change", false);
|
||||
|
||||
if (inPanel) {
|
||||
let panel = aDocument.getElementById(kPanelId);
|
||||
|
@ -14,13 +14,6 @@ add_task(function() {
|
||||
gBrowser.selectedTab = tab1;
|
||||
let zoomResetButton = document.getElementById("zoom-reset-button");
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
info("Cleaning up.");
|
||||
CustomizableUI.reset();
|
||||
gBrowser.removeTab(tab2);
|
||||
gBrowser.removeTab(tab1);
|
||||
});
|
||||
|
||||
is(parseInt(zoomResetButton.label, 10), 100, "Default zoom is 100% for about:mozilla");
|
||||
let zoomChangePromise = promiseObserverNotification("browser-fullZoom:zoomChange");
|
||||
FullZoom.enlarge();
|
||||
@ -38,16 +31,9 @@ add_task(function() {
|
||||
yield zoomResetPromise;
|
||||
is(parseInt(zoomResetButton.label, 10), 100, "Default zoom is 100% for about:mozilla");
|
||||
|
||||
// Test zoom label updates while navigating pages in the same tab.
|
||||
FullZoom.enlarge();
|
||||
yield zoomChangePromise;
|
||||
is(parseInt(zoomResetButton.label, 10), 110, "Zoom is changed to 110% for about:mozilla");
|
||||
yield promiseTabLoadEvent(tab1, "about:home");
|
||||
is(parseInt(zoomResetButton.label, 10), 100, "Default zoom is 100% for about:home");
|
||||
yield promiseTabHistoryNavigation(-1, function() {
|
||||
return parseInt(zoomResetButton.label, 10) == 110;
|
||||
});
|
||||
is(parseInt(zoomResetButton.label, 10), 110, "Zoom is still 110% for about:mozilla");
|
||||
CustomizableUI.reset();
|
||||
gBrowser.removeTab(tab2);
|
||||
gBrowser.removeTab(tab1);
|
||||
});
|
||||
|
||||
function promiseObserverNotification(aObserver) {
|
||||
|
@ -17,7 +17,6 @@ scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUti
|
||||
let {synthesizeDragStart, synthesizeDrop} = ChromeUtils;
|
||||
|
||||
const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
const kTabEventFailureTimeoutInMs = 20000;
|
||||
|
||||
function createDummyXULButton(id, label) {
|
||||
let btn = document.createElementNS(kNSXUL, "toolbarbutton");
|
||||
@ -302,70 +301,3 @@ function waitFor(aTimeout=100) {
|
||||
setTimeout(function() deferred.resolve(), aTimeout);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a load in an existing tab and waits for it to finish (via some event).
|
||||
*
|
||||
* @param aTab The tab to load into.
|
||||
* @param aUrl The url to load.
|
||||
* @param aEventType The load event type to wait for. Defaults to "load".
|
||||
* @return {Promise} resolved when the event is handled.
|
||||
*/
|
||||
function promiseTabLoadEvent(aTab, aURL, aEventType="load") {
|
||||
let deferred = Promise.defer();
|
||||
info("Wait for tab event: " + aEventType);
|
||||
|
||||
let timeoutId = setTimeout(() => {
|
||||
aTab.linkedBrowser.removeEventListener(aEventType, onTabLoad, true);
|
||||
deferred.reject("TabSelect did not happen within " + kTabEventFailureTimeoutInMs + "ms");
|
||||
}, kTabEventFailureTimeoutInMs);
|
||||
|
||||
function onTabLoad(event) {
|
||||
if (event.originalTarget != aTab.linkedBrowser.contentDocument ||
|
||||
event.target.location.href == "about:blank") {
|
||||
info("skipping spurious load event");
|
||||
return;
|
||||
}
|
||||
clearTimeout(timeoutId);
|
||||
aTab.linkedBrowser.removeEventListener(aEventType, onTabLoad, true);
|
||||
info("Tab event received: " + aEventType);
|
||||
deferred.resolve();
|
||||
}
|
||||
aTab.linkedBrowser.addEventListener(aEventType, onTabLoad, true, true);
|
||||
aTab.linkedBrowser.loadURI(aURL);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate back or forward in tab history and wait for it to finish.
|
||||
*
|
||||
* @param aDirection Number to indicate to move backward or forward in history.
|
||||
* @param aConditionFn Function that returns the result of an evaluated condition
|
||||
* that needs to be `true` to resolve the promise.
|
||||
* @return {Promise} resolved when navigation has finished.
|
||||
*/
|
||||
function promiseTabHistoryNavigation(aDirection = -1, aConditionFn) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let timeoutId = setTimeout(() => {
|
||||
gBrowser.removeEventListener("pageshow", listener, true);
|
||||
deferred.reject("Pageshow did not happen within " + kTabEventFailureTimeoutInMs + "ms");
|
||||
}, kTabEventFailureTimeoutInMs);
|
||||
|
||||
function listener(event) {
|
||||
gBrowser.removeEventListener("pageshow", listener, true);
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
if (aConditionFn) {
|
||||
waitForCondition(aConditionFn).then(() => deferred.resolve(),
|
||||
aReason => deferred.reject(aReason));
|
||||
} else {
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
gBrowser.addEventListener("pageshow", listener, true);
|
||||
|
||||
content.history.go(aDirection);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ function test() {
|
||||
function doTestWhenReady(aIsZoomedWindow, aWindow, aCallback) {
|
||||
// Need to wait on two things, the ordering of which is not guaranteed:
|
||||
// (1) the page load, and (2) FullZoom's update to the new page's zoom
|
||||
// level. FullZoom broadcasts "browser-fullZoom:location-change" when its
|
||||
// level. FullZoom broadcasts "FullZoom:TESTS:location-change" when its
|
||||
// update is done. (See bug 856366 for details.)
|
||||
|
||||
let n = 0;
|
||||
@ -30,7 +30,7 @@ function test() {
|
||||
Services.obs.removeObserver(onLocationChange, topic);
|
||||
if (++n == 2)
|
||||
doTest(aIsZoomedWindow, aWindow, aCallback);
|
||||
}, "browser-fullZoom:location-change", false);
|
||||
}, "FullZoom:TESTS:location-change", false);
|
||||
|
||||
browser.loadURI("about:blank");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user