summaryrefslogtreecommitdiffstats
path: root/browser/components/reportbrokensite/test/browser/browser_report_send.js
blob: bf849776d7d1eb1e0723b1789ad3a53ac0455166 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

/* Tests to ensure that sending or canceling reports with
 * the Send and Cancel buttons work (as well as the Okay button)
 */

/* import-globals-from send.js */

"use strict";

Services.scriptloader.loadSubScript(
  getRootDirectory(gTestPath) + "send.js",
  this
);

add_common_setup();

requestLongerTimeout(10);

async function testCancel(menu, url, description) {
  let rbs = await menu.openAndPrefillReportBrokenSite(url, description);
  await rbs.clickCancel();
  ok(!rbs.opened, "clicking Cancel closes Report Broken Site");

  // re-opening the panel, the url and description should be reset
  rbs = await menu.openReportBrokenSite();
  rbs.isMainViewResetToCurrentTab();
  rbs.close();
}

add_task(async function testSendButton() {
  ensureReportBrokenSitePreffedOn();
  ensureReasonOptional();

  const tab1 = await openTab(REPORTABLE_PAGE_URL);

  await testSend(tab1, AppMenu());

  const tab2 = await openTab(REPORTABLE_PAGE_URL);

  await testSend(tab2, ProtectionsPanel(), {
    url: "https://test.org/test/#fake",
    breakageCategory: "media",
    description: "test description",
  });

  closeTab(tab1);
  closeTab(tab2);
});

add_task(async function testCancelButton() {
  ensureReportBrokenSitePreffedOn();

  const tab1 = await openTab(REPORTABLE_PAGE_URL);

  await testCancel(AppMenu());
  await testCancel(ProtectionsPanel());
  await testCancel(HelpMenu());

  const tab2 = await openTab(REPORTABLE_PAGE_URL);

  await testCancel(AppMenu());
  await testCancel(ProtectionsPanel());
  await testCancel(HelpMenu());

  const win2 = await BrowserTestUtils.openNewBrowserWindow();
  const tab3 = await openTab(REPORTABLE_PAGE_URL2, win2);

  await testCancel(AppMenu(win2));
  await testCancel(ProtectionsPanel(win2));
  await testCancel(HelpMenu(win2));

  closeTab(tab3);
  await BrowserTestUtils.closeWindow(win2);

  closeTab(tab1);
  closeTab(tab2);
});