summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/ext/browser/browser_ext_urlbar_clearInput.js
blob: afeff3b8a1188201620855d9a2a7d920af6e8b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

/* global browser */

// This tests the browser.experiments.urlbar.clearInput WebExtension Experiment
// API.

"use strict";

add_task(async function test() {
  // Load a page so that pageproxystate is valid.  When the extension calls
  // clearInput, the pageproxystate should become invalid.
  await BrowserTestUtils.withNewTab("http://example.com/", async () => {
    Assert.notEqual(gURLBar.value, "", "Input is not empty");
    Assert.equal(gURLBar.getAttribute("pageproxystate"), "valid");

    let ext = await loadExtension({
      background: async () => {
        await browser.experiments.urlbar.clearInput();
        browser.test.sendMessage("done");
      },
    });
    await ext.awaitMessage("done");

    Assert.equal(gURLBar.value, "", "Input is empty");
    Assert.equal(gURLBar.getAttribute("pageproxystate"), "invalid");

    await ext.unload();
  });
});