Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* 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/. */
"use strict";
// simulate user initiated loads by entering the URL in the URL-bar code based on
ChromeUtils.defineESModuleGetters(this, {
});
const {
request_count_checking,
test_hint_preload_internal,
test_hint_preload,
} = ChromeUtils.importESModule(
);
const START_VALUE =
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.suggest.quickactions", false]],
});
});
Services.prefs.setBoolPref("network.early-hints.enabled", true);
add_task(async function user_initiated_load() {
// reset the count
let headers = new Headers();
headers.append("X-Early-Hint-Count-Start", "");
await fetch(
{ headers }
);
info("Simple user initiated load");
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
// under normal test conditions using the systemPrincipal as loadingPrincipal
// doesn't elicit a crash, changing the behavior for this test:
Services.prefs.setBoolPref(
"security.disallow_non_local_systemprincipal_in_tests",
true
);
gURLBar.value = START_VALUE;
gURLBar.focus();
EventUtils.synthesizeKey("KEY_Enter");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
// reset the config option
Services.prefs.clearUserPref(
"security.disallow_non_local_systemprincipal_in_tests"
);
// Check url bar and selected tab.
is(
gURLBar.value,
UrlbarTestUtils.trimURL(START_VALUE),
"Urlbar should preserve the value on return keypress"
);
is(gBrowser.selectedTab, tab, "New URL was loaded in the current tab");
let gotRequestCount = await fetch(
).then(response => response.json());
let expectedRequestCount = { hinted: 1, normal: 0 };
await request_count_checking(
"test_preload_user_initiated",
gotRequestCount,
expectedRequestCount
);
// Cleanup.
BrowserTestUtils.removeTab(gBrowser.selectedTab);
});