Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test runs only with pattern: os != 'android'
- Manifest: browser/components/aiwindow/models/tests/xpcshell/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
"use strict";
const { AITab } = ChromeUtils.importESModule(
"moz-src:///browser/components/aiwindow/models/aitab/AITab.sys.mjs"
);
const { buildViewerURL, getViewerBaseURL } = AITab;
const VIEWER_PREF = "browser.smartwindow.aitab.viewerURL";
registerCleanupFunction(() => Services.prefs.clearUserPref(VIEWER_PREF));
add_task(function test_buildViewerURL_puts_config_in_hash() {
const page = { header: { type: "header", title: "Hi <b>x</b>" }, blocks: [] };
const parsed = new URL(url);
Assert.equal(parsed.pathname, "/app", "path is unchanged");
Assert.equal(parsed.search, "", "config is NOT in the query string");
Assert.deepEqual(
JSON.parse(decodeURIComponent(parsed.hash.slice(1))),
page,
"the page config round-trips through the URL hash fragment"
);
});
add_task(function test_buildViewerURL_strips_existing_hash() {
blocks: [],
});
Assert.ok(!url.includes("#stale"), "an existing hash on the base is dropped");
});
add_task(function test_getViewerBaseURL_requires_https() {
Services.prefs.clearUserPref(VIEWER_PREF);
Assert.equal(getViewerBaseURL(), null, "empty pref yields null");
Assert.equal(getViewerBaseURL(), null, "non-https pref yields null");
Services.prefs.setStringPref(VIEWER_PREF, "not a url");
Assert.equal(getViewerBaseURL(), null, "unparseable pref yields null");
Assert.equal(
getViewerBaseURL(),
"an https pref is returned with any hash stripped"
);
});