1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
8 * Check from content process if DOM Window has a conforming
9 * manifest link relationship.
10 * @param aContent DOM Window to check.
11 * @return {Promise<Boolean>}
13 contentHasManifestLink(aContent) {
14 if (!aContent || isXULBrowser(aContent)) {
15 throw new TypeError("Invalid input.");
17 return checkForManifest(aContent);
21 * Check from a XUL browser (parent process) if it's content document has a
22 * manifest link relationship.
23 * @param aBrowser The XUL browser to check.
26 async browserHasManifestLink(aBrowser) {
27 if (!isXULBrowser(aBrowser)) {
28 throw new TypeError("Invalid input.");
31 const actor = aBrowser.browsingContext.currentWindowGlobal.getActor(
34 const reply = await actor.sendQuery("DOM:WebManifest:hasManifestLink");
39 function isXULBrowser(aBrowser) {
40 if (!aBrowser || !aBrowser.namespaceURI || !aBrowser.localName) {
44 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
45 return aBrowser.namespaceURI === XUL_NS && aBrowser.localName === "browser";
48 function checkForManifest(aWindow) {
49 // Only top-level browsing contexts are valid.
50 if (!aWindow || aWindow.top !== aWindow) {
53 const elem = aWindow.document.querySelector("link[rel~='manifest']");
54 // Only if we have an element and a non-empty href attribute.
55 if (!elem || !elem.getAttribute("href")) {
61 var EXPORTED_SYMBOLS = ["ManifestFinder"];