browser_allocations_reload_no_devtools.js (1285B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Record allocations while reloading the page without anything related to DevTools running 7 8 const TEST_URL = 9 "http://example.com/browser/devtools/client/framework/test/allocations/reloaded-page.html"; 10 11 async function testScript() { 12 await BrowserTestUtils.reloadTab(gBrowser.selectedTab); 13 14 // eslint-disable-next-line mozilla/no-arbitrary-setTimeout 15 await new Promise(resolve => setTimeout(resolve, 1000)); 16 } 17 18 add_task(async function () { 19 const tab = await addTab(TEST_URL); 20 21 // Run the test scenario first before recording in order to load all the 22 // modules. Otherwise they get reported as "still allocated" objects, 23 // whereas we do expect them to be kept in memory as they are loaded via 24 // the main DevTools loader, which keeps the module loaded until the 25 // shutdown of Firefox 26 await testScript(); 27 28 await startRecordingAllocations({ 29 alsoRecordContentProcess: true, 30 }); 31 32 // Now, run the test script. This time, we record this run. 33 for (let i = 0; i < 10; i++) { 34 await testScript(); 35 } 36 37 await stopRecordingAllocations("reload-no-devtools", { 38 alsoRecordContentProcess: true, 39 }); 40 41 gBrowser.removeTab(tab); 42 });