browser_aboutStopReload.js (5279B)
1 async function waitForNoAnimation(elt) { 2 return TestUtils.waitForCondition(() => !elt.hasAttribute("animate")); 3 } 4 5 async function getAnimatePromise(elt) { 6 return BrowserTestUtils.waitForAttribute("animate", elt).then(() => 7 Assert.ok(true, `${elt.id} should animate`) 8 ); 9 } 10 11 function stopReloadMutationCallback() { 12 Assert.ok( 13 false, 14 "stop-reload's animate attribute should not have been mutated" 15 ); 16 } 17 18 // Force-enable the animation 19 gReduceMotionOverride = false; 20 21 add_task(async function checkDontShowStopOnNewTab() { 22 let stopReloadContainer = document.getElementById("stop-reload-button"); 23 let stopReloadContainerObserver = new MutationObserver( 24 stopReloadMutationCallback 25 ); 26 27 await waitForNoAnimation(stopReloadContainer); 28 stopReloadContainerObserver.observe(stopReloadContainer, { 29 attributeFilter: ["animate"], 30 }); 31 let tab = await BrowserTestUtils.openNewForegroundTab({ 32 gBrowser, 33 opening: "about:robots", 34 waitForStateStop: true, 35 }); 36 BrowserTestUtils.removeTab(tab); 37 38 Assert.ok( 39 true, 40 "Test finished: stop-reload does not animate when navigating to local URI on new tab" 41 ); 42 stopReloadContainerObserver.disconnect(); 43 }); 44 45 add_task(async function checkDontShowStopFromLocalURI() { 46 let stopReloadContainer = document.getElementById("stop-reload-button"); 47 let stopReloadContainerObserver = new MutationObserver( 48 stopReloadMutationCallback 49 ); 50 51 let tab = await BrowserTestUtils.openNewForegroundTab({ 52 gBrowser, 53 opening: "about:robots", 54 waitForStateStop: true, 55 }); 56 await waitForNoAnimation(stopReloadContainer); 57 stopReloadContainerObserver.observe(stopReloadContainer, { 58 attributeFilter: ["animate"], 59 }); 60 BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, "about:mozilla"); 61 BrowserTestUtils.removeTab(tab); 62 63 Assert.ok( 64 true, 65 "Test finished: stop-reload does not animate when navigating between local URIs" 66 ); 67 stopReloadContainerObserver.disconnect(); 68 }); 69 70 add_task(async function checkDontShowStopFromNonLocalURI() { 71 let stopReloadContainer = document.getElementById("stop-reload-button"); 72 let stopReloadContainerObserver = new MutationObserver( 73 stopReloadMutationCallback 74 ); 75 76 let tab = await BrowserTestUtils.openNewForegroundTab({ 77 gBrowser, 78 opening: "https://example.com", 79 waitForStateStop: true, 80 }); 81 await waitForNoAnimation(stopReloadContainer); 82 stopReloadContainerObserver.observe(stopReloadContainer, { 83 attributeFilter: ["animate"], 84 }); 85 BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, "about:mozilla"); 86 BrowserTestUtils.removeTab(tab); 87 88 Assert.ok( 89 true, 90 "Test finished: stop-reload does not animate when navigating to local URI from non-local URI" 91 ); 92 stopReloadContainerObserver.disconnect(); 93 }); 94 95 add_task(async function checkDoShowStopOnNewTab() { 96 let stopReloadContainer = document.getElementById("stop-reload-button"); 97 let reloadButton = document.getElementById("reload-button"); 98 let stopPromise = BrowserTestUtils.waitForAttribute( 99 "displaystop", 100 reloadButton 101 ); 102 103 await waitForNoAnimation(stopReloadContainer); 104 105 let tab = await BrowserTestUtils.openNewForegroundTab({ 106 gBrowser, 107 opening: "https://example.com", 108 waitForStateStop: true, 109 }); 110 await stopPromise; 111 await waitForNoAnimation(stopReloadContainer); 112 BrowserTestUtils.removeTab(tab); 113 114 info( 115 "Test finished: stop-reload shows stop when navigating to non-local URI during tab opening" 116 ); 117 }); 118 119 add_task(async function checkAnimateStopOnTabAfterTabFinishesOpening() { 120 let stopReloadContainer = document.getElementById("stop-reload-button"); 121 122 await waitForNoAnimation(stopReloadContainer); 123 let tab = await BrowserTestUtils.openNewForegroundTab({ 124 gBrowser, 125 waitForStateStop: true, 126 }); 127 await TestUtils.waitForCondition(() => { 128 info( 129 "Waiting for tabAnimationsInProgress to equal 0, currently " + 130 gBrowser.tabAnimationsInProgress 131 ); 132 return !gBrowser.tabAnimationsInProgress; 133 }); 134 let animatePromise = getAnimatePromise(stopReloadContainer); 135 BrowserTestUtils.startLoadingURIString( 136 tab.linkedBrowser, 137 "https://example.com" 138 ); 139 await animatePromise; 140 BrowserTestUtils.removeTab(tab); 141 142 info( 143 "Test finished: stop-reload animates when navigating to non-local URI on new tab after tab has opened" 144 ); 145 }); 146 147 add_task(async function checkDoShowStopFromLocalURI() { 148 let stopReloadContainer = document.getElementById("stop-reload-button"); 149 150 await waitForNoAnimation(stopReloadContainer); 151 let tab = await BrowserTestUtils.openNewForegroundTab({ 152 gBrowser, 153 opening: "about:robots", 154 waitForStateStop: true, 155 }); 156 await TestUtils.waitForCondition(() => { 157 info( 158 "Waiting for tabAnimationsInProgress to equal 0, currently " + 159 gBrowser.tabAnimationsInProgress 160 ); 161 return !gBrowser.tabAnimationsInProgress; 162 }); 163 let animatePromise = getAnimatePromise(stopReloadContainer); 164 BrowserTestUtils.startLoadingURIString( 165 tab.linkedBrowser, 166 "https://example.com" 167 ); 168 await animatePromise; 169 await waitForNoAnimation(stopReloadContainer); 170 BrowserTestUtils.removeTab(tab); 171 172 info( 173 "Test finished: stop-reload animates when navigating to non-local URI from local URI" 174 ); 175 });