blob: 0481be3703075ec4e46b52796e40cd02d3f68ff9 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* 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";
const { openDocLink } = require("devtools/client/shared/link");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const {
createFactory,
PureComponent,
} = require("devtools/client/shared/vendor/react");
const { a, p } = require("devtools/client/shared/vendor/react-dom-factories");
const FluentReact = require("devtools/client/shared/vendor/fluent-react");
const Localized = createFactory(FluentReact.Localized);
/**
* This component displays an "Open JSON" link for the Manifest
*/
class ManifestJsonLink extends PureComponent {
static get propTypes() {
return {
url: PropTypes.string.isRequired,
};
}
get shouldRenderLink() {
const { url } = this.props;
// Firefox blocks the loading of Data URLs with mimetypes manifest+json unless
// explicitly typed by the user in the address bar.
// So we are not showing the link in this case.
// See more details in this post:
// https://blog.mozilla.org/security/2017/11/27/blocking-top-level-navigations-data-urls-firefox-59/
return !url.startsWith("data:");
}
renderLink() {
const { url } = this.props;
return a(
{
className: "js-manifest-json-link devtools-ellipsis-text",
href: "#",
title: url,
onClick: () => openDocLink(url),
},
url
);
}
render() {
return p(
{ className: "manifest-json-link" },
this.shouldRenderLink
? this.renderLink()
: Localized({ id: "manifest-json-link-data-url" })
);
}
}
module.exports = ManifestJsonLink;
|