1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
6 async function handleCommandLine(args, state) {
8 let target = Services.urlFormatter.formatURLPref(
9 "browser.shell.defaultBrowserAgent.thanksURL"
12 const EXISTING_FILE = Cc["@mozilla.org/file/local;1"].createInstance(
15 EXISTING_FILE.initWithPath(getTestFilePath("dummy.pdf"));
17 if (state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH) {
18 newWinPromise = BrowserTestUtils.waitForNewWindow({
19 url: target, // N.b.: trailing slashes matter when matching.
23 let cmdLineHandler = Cc["@mozilla.org/browser/final-clh;1"].getService(
24 Ci.nsICommandLineHandler
27 let fakeCmdLine = Cu.createCommandLine(args, EXISTING_FILE.parent, state);
28 cmdLineHandler.handle(fakeCmdLine);
31 let newWin = await newWinPromise;
32 await BrowserTestUtils.closeWindow(newWin);
34 BrowserTestUtils.removeTab(gBrowser.selectedTab);
38 // Launching from the WDBA should open the "thanks" page and should send a
40 add_task(async function test_launched_to_handle_default_browser_agent() {
41 await handleCommandLine(
42 ["-to-handle-default-browser-agent"],
43 Ci.nsICommandLine.STATE_INITIAL_LAUNCH
46 TelemetryTestUtils.assertEvents(
47 [{ extra: { name: "default-browser-agent" } }],
49 category: "browser.launched_to_handle",
50 method: "system_notification",