Bug 1505929 - Add FxA onboarding card, pref on CFR and ASR and bug fixes to Activity Stream r=k88hudson,Mardak

Differential Revision: https://phabricator.services.mozilla.com/D11375
This commit is contained in:
Ricky Rosario
2018-11-10 19:13:10 +00:00
parent 9331299b4e
commit b7c4dae26f
85 changed files with 1509 additions and 1122 deletions

View File

@@ -247,10 +247,6 @@ export class SnippetsProvider {
}
}
_noSnippetFallback() {
// TODO
}
_showRemoteSnippets() {
const snippetsEl = document.getElementById(this.elementId);
const payload = this.snippetsMap.get("snippets");
@@ -272,6 +268,8 @@ export class SnippetsProvider {
// eslint-disable-next-line no-unsanitized/property
snippetsEl.innerHTML = payload;
this._logIfDevtools("Successfully added snippets.");
// Scripts injected by innerHTML are inactive, so we have to relocate them
// through DOM manipulation to activate their contents.
for (const scriptEl of snippetsEl.getElementsByTagName("script")) {
@@ -290,6 +288,13 @@ export class SnippetsProvider {
}
}
// istanbul ignore next
_logIfDevtools(text) {
if (this.devtoolsEnabled) {
console.log("Legacy snippets:", text); // eslint-disable-line no-console
}
}
/**
* init - Fetch the snippet payload and show snippets
*
@@ -304,8 +309,11 @@ export class SnippetsProvider {
appData: {},
elementId: "snippets",
connect: true,
devtoolsEnabled: false,
}, options);
this._logIfDevtools("Initializing...");
// Add listener so we know when snippets are blocked on other pages
if (global.RPMAddMessageListener) {
global.RPMAddMessageListener("ActivityStream:MainToContent", this._onAction);
@@ -337,12 +345,14 @@ export class SnippetsProvider {
try {
this._showRemoteSnippets();
} catch (e) {
this._noSnippetFallback(e);
this._logIfDevtools("Problem inserting remote snippets!");
console.error(e); // eslint-disable-line no-console
}
window.dispatchEvent(new Event(SNIPPETS_ENABLED_EVENT));
this.initialized = true;
this._logIfDevtools("Finished initializing.");
}
uninit() {
@@ -397,11 +407,7 @@ export function addSnippetsSubscriber(store) {
location.hash !== "#asrouter"
) {
initializing = true;
await snippets.init({appData: state.Snippets});
// istanbul ignore if
if (state.Prefs.values["asrouter.devtoolsEnabled"]) {
console.log("Legacy snippets initialized"); // eslint-disable-line no-console
}
await snippets.init({appData: state.Snippets, devtoolsEnabled: state.Prefs.values["asrouter.devtoolsEnabled"]});
initializing = false;
/** If we should remove snippets... */