summaryrefslogtreecommitdiffstats
path: root/toolkit/components/viewsource/test/browser/browser_open_docgroup.js
blob: 071635b998d6e30bf512a6d3f31485da4ee3ba14 (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
"use strict";

/**
 * Very basic smoketests for the View Source feature, which also
 * forces on the DocGroup mismatch check that was added in
 * bug 1340719.
 */

add_setup(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [["extensions.throw_on_docgroup_mismatch.enabled", true]],
  });
});

/**
 * Tests that we can open View Source in a tab.
 */
add_task(async function test_view_source_in_tab() {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: "http://example.com",
    },
    async function (browser) {
      let sourceTab = await openViewSourceForBrowser(browser);
      let sourceBrowser = sourceTab.linkedBrowser;

      await SpecialPowers.spawn(sourceBrowser, [], async function () {
        Assert.equal(
          content.document.body.id,
          "viewsource",
          "View source mode enabled"
        );
      });

      BrowserTestUtils.removeTab(sourceTab);
    }
  );

  await SpecialPowers.popPrefEnv();
});