Bug 1504157 - Make onsize event triggered once. r=smaug, a=test-only
authorLiang-Heng Chen <xeonchen@gmail.com>
Thu, 07 Feb 2019 20:34:06 +0000
changeset 512950 5a11b523f8e332b43d3d83277bb9d5947b919f1a
parent 512949 e4896e3e5eb2e8caf0f17b4e49a1fdab07a91946
child 512951 9b3d629cf829c77442955d7efd9101a73511f187
push id10656
push userryanvm@gmail.com
push dateFri, 08 Feb 2019 19:05:01 +0000
treeherdermozilla-beta@fc9047475850 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, test-only
bugs1504157
milestone66.0
Bug 1504157 - Make onsize event triggered once. r=smaug, a=test-only Avoid the condition been checked twice. Differential Revision: https://phabricator.services.mozilla.com/D18961
browser/components/resistfingerprinting/test/browser/head.js
--- a/browser/components/resistfingerprinting/test/browser/head.js
+++ b/browser/components/resistfingerprinting/test/browser/head.js
@@ -185,42 +185,42 @@ async function testWindowSizeSetting(aBr
         // size. We need this to trigger 'onresize' event.
         let initWinFeatures = "width=" + input.initWidth + ",height=" + input.initHeight;
         win = content.open("http://example.net/", "", initWinFeatures);
         win.onload = () => resolve();
       });
 
       // Test inner/outerWidth.
       await new Promise(resolve => {
-        win.onresize = () => {
+        win.addEventListener("resize", () => {
           is(win.screen.width, input.targetWidth,
             "The screen.width has a correct rounded value");
           is(win.innerWidth, input.targetWidth,
             "The window.innerWidth has a correct rounded value");
 
           resolve();
-        };
+        }, { once: true });
 
         if (input.testOuter) {
           win.outerWidth = input.settingWidth;
         } else {
           win.innerWidth = input.settingWidth;
         }
       });
 
       // Test inner/outerHeight.
       await new Promise(resolve => {
-        win.onresize = () => {
+        win.addEventListener("resize", () => {
           is(win.screen.height, input.targetHeight,
             "The screen.height has a correct rounded value");
           is(win.innerHeight, input.targetHeight,
             "The window.innerHeight has a correct rounded value");
 
           resolve();
-        };
+        }, { once: true });
 
         if (input.testOuter) {
           win.outerHeight = input.settingHeight;
         } else {
           win.innerHeight = input.settingHeight;
         }
       });