summaryrefslogtreecommitdiffstats
path: root/browser/components/places/tests/browser/interactions/browser_interactions_referrer.js
blob: fda93bfc5a1c65578eb886e35158865572d07764 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
 * Tests page view time recording for interactions.
 */

const TEST_REFERRER_URL = "https://example.org/browser";
const TEST_URL = "https://example.org/browser/browser";

add_task(async function test_interactions_referrer() {
  await Interactions.reset();
  await BrowserTestUtils.withNewTab(TEST_REFERRER_URL, async browser => {
    let ReferrerInfo = Components.Constructor(
      "@mozilla.org/referrer-info;1",
      "nsIReferrerInfo",
      "init"
    );

    // Load a new URI with a specific referrer.
    let referrerInfo1 = new ReferrerInfo(
      Ci.nsIReferrerInfo.EMPTY,
      true,
      Services.io.newURI(TEST_REFERRER_URL)
    );
    browser.loadURI(Services.io.newURI(TEST_URL), {
      referrerInfo: referrerInfo1,
      triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
        {}
      ),
    });
    await BrowserTestUtils.browserLoaded(browser, true, TEST_URL);
  });
  await assertDatabaseValues([
    {
      url: TEST_REFERRER_URL,
      referrer_url: null,
    },
    {
      url: TEST_URL,
      referrer_url: TEST_REFERRER_URL,
    },
  ]);
});