Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: browser/components/urlbar/tests/unit/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
/**
* These tests unit test the functionality of the functions in UrlbarUtils.
* Some functions are bigger, and split out into sepearate test_UrlbarUtils_* files.
*/
"use strict";
const { PrivateBrowsingUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PrivateBrowsingUtils.sys.mjs"
);
const { PlacesUIUtils } = ChromeUtils.importESModule(
"resource:///modules/PlacesUIUtils.sys.mjs"
);
let sandbox;
add_setup(function () {
sandbox = sinon.createSandbox();
});
add_task(function test_addToUrlbarHistory() {
sandbox.stub(PlacesUIUtils, "markPageAsTyped");
sandbox.stub(PrivateBrowsingUtils, "isWindowPrivate").returns(false);
Assert.ok(
PlacesUIUtils.markPageAsTyped.calledOnce,
"Should have marked a simple URL as typed."
);
PlacesUIUtils.markPageAsTyped.resetHistory();
UrlbarUtils.addToUrlbarHistory();
Assert.ok(
PlacesUIUtils.markPageAsTyped.notCalled,
"Should not have attempted to mark a null URL as typed."
);
PlacesUIUtils.markPageAsTyped.resetHistory();
Assert.ok(
PlacesUIUtils.markPageAsTyped.notCalled,
"Should not have marked a URL containing a space as typed."
);
PlacesUIUtils.markPageAsTyped.resetHistory();
Assert.ok(
PlacesUIUtils.markPageAsTyped.notCalled,
"Should not have marked a URL containing a control character as typed."
);
PlacesUIUtils.markPageAsTyped.resetHistory();
PrivateBrowsingUtils.isWindowPrivate.returns(true);
Assert.ok(
PlacesUIUtils.markPageAsTyped.notCalled,
"Should not have marked a URL provided by a private browsing page as typed."
);
PlacesUIUtils.markPageAsTyped.resetHistory();
});