browser_harautomation_simple.js (1132B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const HAR_FILENAME = "test_filename.har"; 7 8 // We expect the HAR file to be created on reload in profD/har/logs 9 const HAR_PATH = ["har", "logs", HAR_FILENAME]; 10 11 /** 12 * Smoke test for automated HAR export. 13 * Note that the `enableAutoExportToFile` is set from browser-harautomation.ini 14 * because the preference needs to be set before starting the browser. 15 */ 16 add_task(async function () { 17 // Set a simple test filename for the exported HAR. 18 await pushPref("devtools.netmonitor.har.defaultFileName", "test_filename"); 19 20 const tab = await addTab(SIMPLE_URL); 21 const toolbox = await gDevTools.showToolboxForTab(tab, { 22 toolId: "inspector", 23 }); 24 25 await reloadBrowser(); 26 27 info("Wait until the HAR file is created in the profile directory"); 28 const harFile = new FileUtils.File( 29 PathUtils.join(PathUtils.profileDir, ...HAR_PATH) 30 ); 31 32 await waitUntil(() => harFile.exists()); 33 ok(harFile.exists(), "HAR file was automatically created"); 34 35 await toolbox.destroy(); 36 await removeTab(tab); 37 });