summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_remoteness_switch.js
blob: 364eeff1b2359d37649497d7739516deed47d774 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"use strict";

/**
 * Verify that when loading and going back/forward through history between URLs
 * loaded in the content process, and URLs loaded in the parent process, we
 * don't set the URL for the tab to about:blank inbetween the loads.
 */
add_task(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.navigation.requireUserInteraction", false]],
  });
  let url = "http://www.example.com/foo.html";
  await BrowserTestUtils.withNewTab(
    { gBrowser, url },
    async function (browser) {
      let wpl = {
        onLocationChange(unused, unused2, location) {
          if (location.schemeIs("about")) {
            is(
              location.spec,
              "about:config",
              "Only about: location change should be for about:preferences"
            );
          } else {
            is(
              location.spec,
              url,
              "Only non-about: location change should be for the http URL we're dealing with."
            );
          }
        },
      };
      gBrowser.addProgressListener(wpl);

      let didLoad = BrowserTestUtils.browserLoaded(
        browser,
        null,
        function (loadedURL) {
          return loadedURL == "about:config";
        }
      );
      BrowserTestUtils.loadURIString(browser, "about:config");
      await didLoad;

      gBrowser.goBack();
      await BrowserTestUtils.browserLoaded(browser, null, function (loadedURL) {
        return url == loadedURL;
      });
      gBrowser.goForward();
      await BrowserTestUtils.browserLoaded(browser, null, function (loadedURL) {
        return loadedURL == "about:config";
      });
      gBrowser.removeProgressListener(wpl);
    }
  );
});