Bug 1553173 - Import about:logins components as JS modules. r=MattN

Differential Revision: https://phabricator.services.mozilla.com/D32052

--HG--
rename : browser/components/aboutlogins/tests/mochitest/aboutlogins_common.js => browser/components/aboutlogins/tests/chrome/aboutlogins_common.js
rename : browser/components/aboutlogins/tests/mochitest/mochitest.ini => browser/components/aboutlogins/tests/chrome/chrome.ini
rename : browser/components/aboutlogins/tests/mochitest/test_login_filter.html => browser/components/aboutlogins/tests/chrome/test_login_filter.html
rename : browser/components/aboutlogins/tests/mochitest/test_login_item.html => browser/components/aboutlogins/tests/chrome/test_login_item.html
rename : browser/components/aboutlogins/tests/mochitest/test_login_list.html => browser/components/aboutlogins/tests/chrome/test_login_list.html
rename : browser/components/aboutlogins/tests/mochitest/test_modal_input.html => browser/components/aboutlogins/tests/chrome/test_modal_input.html
rename : browser/components/aboutlogins/tests/mochitest/test_reflected_fluent_element.html => browser/components/aboutlogins/tests/chrome/test_reflected_fluent_element.html
extra : moz-landing-system : lando
This commit is contained in:
Jared Wein 2019-05-24 19:26:50 +00:00
Родитель fe77911a5f
Коммит f9cb4ec2b6
17 изменённых файлов: 52 добавлений и 47 удалений

Просмотреть файл

@ -9,13 +9,12 @@
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; object-src 'none'; script-src resource: chrome:; img-src data: blob:;"/>
<title data-l10n-id="about-logins-page-title"></title>
<link rel="localization" href="browser/aboutLogins.ftl">
<script defer="defer" src="chrome://browser/content/aboutlogins/components/reflected-fluent-element.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/components/copy-to-clipboard-button.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/components/login-filter.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/components/login-item.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/components/login-list.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/components/login-list-item.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/components/modal-input.js"></script>
<script type="module" src="chrome://browser/content/aboutlogins/components/copy-to-clipboard-button.js"></script>
<script type="module" src="chrome://browser/content/aboutlogins/components/login-filter.js"></script>
<script type="module" src="chrome://browser/content/aboutlogins/components/login-item.js"></script>
<script type="module" src="chrome://browser/content/aboutlogins/components/login-list.js"></script>
<script type="module" src="chrome://browser/content/aboutlogins/components/login-list-item.js"></script>
<script type="module" src="chrome://browser/content/aboutlogins/components/modal-input.js"></script>
<script defer="defer" src="chrome://browser/content/aboutlogins/aboutLogins.js"></script>
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css">
<link rel="stylesheet" href="chrome://browser/content/aboutlogins/aboutLogins.css">

Просмотреть файл

@ -0,0 +1,7 @@
"use strict";
module.exports = {
parserOptions: {
sourceType: "module",
},
};

Просмотреть файл

@ -2,9 +2,9 @@
* 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/. */
/* globals ReflectedFluentElement */
import ReflectedFluentElement from "chrome://browser/content/aboutlogins/components/reflected-fluent-element.js";
class CopyToClipboardButton extends ReflectedFluentElement {
export default class CopyToClipboardButton extends ReflectedFluentElement {
static get BUTTON_RESET_TIMEOUT() {
return 5000;
}

Просмотреть файл

@ -2,9 +2,9 @@
* 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/. */
/* globals ReflectedFluentElement */
import ReflectedFluentElement from "chrome://browser/content/aboutlogins/components/reflected-fluent-element.js";
class LoginFilter extends ReflectedFluentElement {
export default class LoginFilter extends ReflectedFluentElement {
connectedCallback() {
if (this.children.length) {
return;

Просмотреть файл

@ -2,9 +2,9 @@
* 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/. */
/* globals ReflectedFluentElement */
import ReflectedFluentElement from "chrome://browser/content/aboutlogins/components/reflected-fluent-element.js";
class LoginItem extends ReflectedFluentElement {
export default class LoginItem extends ReflectedFluentElement {
constructor() {
super();
this._login = {};

Просмотреть файл

@ -2,7 +2,7 @@
* 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/. */
class LoginListItem extends HTMLElement {
export default class LoginListItem extends HTMLElement {
constructor(login) {
super();
this._login = login;

Просмотреть файл

@ -2,9 +2,10 @@
* 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/. */
/* globals ReflectedFluentElement, LoginListItem */
import LoginListItem from "chrome://browser/content/aboutlogins/components/login-list-item.js";
import ReflectedFluentElement from "chrome://browser/content/aboutlogins/components/reflected-fluent-element.js";
class LoginList extends ReflectedFluentElement {
export default class LoginList extends ReflectedFluentElement {
constructor() {
super();
this._logins = [];

Просмотреть файл

@ -2,9 +2,9 @@
* 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/. */
/* globals ReflectedFluentElement */
import ReflectedFluentElement from "chrome://browser/content/aboutlogins/components/reflected-fluent-element.js";
class ModalInput extends ReflectedFluentElement {
export default class ModalInput extends ReflectedFluentElement {
static get LOCKED_PASSWORD_DISPLAY() {
return "••••••••";
}

Просмотреть файл

@ -2,7 +2,7 @@
* 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/. */
class ReflectedFluentElement extends HTMLElement {
export default class ReflectedFluentElement extends HTMLElement {
_isReflectedAttributePresent(attr) {
return this.constructor.reflectedFluentIDs.includes(attr.name);
}

Просмотреть файл

@ -18,4 +18,4 @@ FINAL_TARGET_FILES.actors += [
]
BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini']

Просмотреть файл

@ -26,13 +26,17 @@ function importDependencies(templateFrame, destinationEl) {
}
function stubFluentL10n(argsMap) {
document.l10n = {
setAttributes(element, id, args) {
element.setAttribute("data-l10n-id", id);
for (let attrName of Object.keys(argsMap)) {
let varName = argsMap[attrName];
element.setAttribute(attrName, args[varName]);
}
Object.defineProperty(document, "l10n", {
configurable: true,
writable: true,
value: {
setAttributes(element, id, args) {
element.setAttribute("data-l10n-id", id);
for (let attrName of Object.keys(argsMap)) {
let varName = argsMap[attrName];
element.setAttribute(attrName, args[varName]);
}
},
},
};
});
}

Просмотреть файл

@ -6,12 +6,10 @@ Test the login-filter component
<head>
<meta charset="utf-8">
<title>Test the login-filter component</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="reflected-fluent-element.js"></script>
<script src="login-filter.js"></script>
<script src="login-list-item.js"></script>
<script src="login-list.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="module" src="login-filter.js"></script>
<script type="module" src="login-list.js"></script>
<script src="aboutlogins_common.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>

Просмотреть файл

@ -6,10 +6,9 @@ Test the login-item component
<head>
<meta charset="utf-8">
<title>Test the login-item component</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="reflected-fluent-element.js"></script>
<script src="login-item.js"></script>
<script src="modal-input.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="module" src="login-item.js"></script>
<script type="module" src="modal-input.js"></script>
<script src="aboutlogins_common.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>

Просмотреть файл

@ -6,10 +6,8 @@ Test the login-list component
<head>
<meta charset="utf-8">
<title>Test the login-list component</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="reflected-fluent-element.js"></script>
<script src="login-list-item.js"></script>
<script src="login-list.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="module" src="login-list.js"></script>
<script src="aboutlogins_common.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>

Просмотреть файл

@ -6,9 +6,8 @@ Test the modal-input component
<head>
<meta charset="utf-8">
<title>Test the modal-input component</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="reflected-fluent-element.js"></script>
<script src="modal-input.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="module" src="modal-input.js"></script>
<script src="aboutlogins_common.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>

Просмотреть файл

@ -6,8 +6,7 @@ Test the reflected-fluent-element component
<head>
<meta charset="utf-8">
<title>Test the reflected-fluent-element component</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="reflected-fluent-element.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="aboutlogins_common.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
@ -75,6 +74,7 @@ add_task(async function setup() {
for (let scriptSrc of ["login-filter.js", "login-item.js", "login-list.js"]) {
let scriptEl = document.createElement("script");
scriptEl.setAttribute("src", scriptSrc);
scriptEl.setAttribute("type", "module");
document.head.appendChild(scriptEl);
}
});