Bug 1372309 - make test-ui-action-button turn off photon and make it work on hidpi devices, r?aswan
MozReview-Commit-ID: Jwwxvv8LQST
--- a/addon-sdk/source/test/test-ui-action-button.js
+++ b/addon-sdk/source/test/test-ui-action-button.js
@@ -801,16 +801,19 @@ exports['test button click'] = function*
'button click works');
yield close(window);
loader.unload();
}
exports['test button icon set'] = function(assert) {
+ Cu.import("resource://gre/modules/Services.jsm");
+ Services.prefs.setBoolPref("browser.photon.structure.enabled", false);
+
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
let loader = Loader(module);
let { ActionButton } = loader.require('sdk/ui');
let { data } = loader.require('sdk/self');
// Test remote icon set
assert.throws(
() => ActionButton({
@@ -832,39 +835,44 @@ exports['test button icon set'] = functi
'32': './icon32.png',
'64': './icon64.png'
}
});
let { node, id: widgetId } = getWidget(button.id);
let { devicePixelRatio } = node.ownerGlobal;
- let size = 16 * devicePixelRatio;
+ let size = [5, 16, 32, 64].find(x => (16 * devicePixelRatio) <= x);
assert.equal(node.getAttribute('image'), data.url(button.icon[size].substr(2)),
'the icon is set properly in navbar');
- size = 32 * devicePixelRatio;
+ size = [5, 16, 32, 64].find(x => (32 * devicePixelRatio) <= x);
CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_PANEL);
assert.equal(node.getAttribute('image'), data.url(button.icon[size].substr(2)),
'the icon is set properly in panel');
// Using `loader.unload` without move back the button to the original area
// raises an error in the CustomizableUI. This is doesn't happen if the
// button is moved manually from navbar to panel. I believe it has to do
// with `addWidgetToArea` method, because even with a `timeout` the issue
// persist.
CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
+ Cu.import("resource://gre/modules/Services.jsm");
+ Services.prefs.clearUserPref("browser.photon.structure.enabled");
loader.unload();
}
exports['test button icon set with only one option'] = function(assert) {
+ Cu.import("resource://gre/modules/Services.jsm");
+ Services.prefs.setBoolPref("browser.photon.structure.enabled", false);
+
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
let loader = Loader(module);
let { ActionButton } = loader.require('sdk/ui');
let { data } = loader.require('sdk/self');
// Test remote icon set
assert.throws(
() => ActionButton({
@@ -897,16 +905,18 @@ exports['test button icon set with only
// Using `loader.unload` without move back the button to the original area
// raises an error in the CustomizableUI. This is doesn't happen if the
// button is moved manually from navbar to panel. I believe it has to do
// with `addWidgetToArea` method, because even with a `timeout` the issue
// persist.
CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
+ Cu.import("resource://gre/modules/Services.jsm");
+ Services.prefs.clearUserPref("browser.photon.structure.enabled");
loader.unload();
}
exports['test button state validation'] = function(assert) {
let loader = Loader(module);
let { ActionButton } = loader.require('sdk/ui');
let { browserWindows } = loader.require('sdk/windows');