Bug 1372309 - make test-ui-action-button turn off photon and make it work on hidpi devices, r?aswan draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 14 Jun 2017 11:47:28 +0100
changeset 594797 8fe0866fa949baf1059c7d6159211caf29911bbd
parent 594796 f43d002cdbf7c28ce6089f072f07fce28efc9aa9
child 594798 6a8d0b956dc064fa51f24c546e6cd0d035c8f6fc
push id64146
push userbmo:gijskruitbosch+bugs@gmail.com
push dateThu, 15 Jun 2017 13:55:41 +0000
reviewersaswan
bugs1372309
milestone56.0a1
Bug 1372309 - make test-ui-action-button turn off photon and make it work on hidpi devices, r?aswan MozReview-Commit-ID: Jwwxvv8LQST
addon-sdk/source/test/test-ui-action-button.js
--- 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');