summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/browser/browser_content_url_annotation.js
blob: 29332ce03631f7cc393683c00f6301c2db5b1e14 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */
/* global Services, requestLongerTimeout, TestUtils, BrowserTestUtils,
 ok, info, dump, is, Ci, Cu, Components, ctypes,
 gBrowser, add_task, addEventListener, removeEventListener, ContentTask */

"use strict";

// Running this test in ASAN is slow.
requestLongerTimeout(2);

/**
 * Removes a file from a directory. This is a no-op if the file does not
 * exist.
 *
 * @param directory
 *        The nsIFile representing the directory to remove from.
 * @param filename
 *        A string for the file to remove from the directory.
 */
function removeFile(directory, filename) {
  let file = directory.clone();
  file.append(filename);
  if (file.exists()) {
    file.remove(false);
  }
}

/**
 * Returns the directory where crash dumps are stored.
 *
 * @return nsIFile
 */
function getMinidumpDirectory() {
  let dir = Services.dirsvc.get("ProfD", Ci.nsIFile);
  dir.append("minidumps");
  return dir;
}

/**
 * Checks that the URL is correctly annotated on a content process crash.
 */
add_task(async function test_content_url_annotation() {
  let url =
    "https://example.com/browser/toolkit/content/tests/browser/file_redirect.html";
  let redirect_url =
    "https://example.com/browser/toolkit/content/tests/browser/file_redirect_to.html";

  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
    },
    async function (browser) {
      ok(browser.isRemoteBrowser, "Should be a remote browser");

      // file_redirect.html should send us to file_redirect_to.html
      let promise = BrowserTestUtils.waitForContentEvent(
        browser,
        "RedirectDone",
        true,
        null,
        true
      );
      BrowserTestUtils.loadURIString(browser, url);
      await promise;

      // Crash the tab
      let annotations = await BrowserTestUtils.crashFrame(browser);

      ok("URL" in annotations, "annotated a URL");
      is(
        annotations.URL,
        redirect_url,
        "Should have annotated the URL after redirect"
      );
    }
  );
});