From 678c6cc941234a6ff1cca513aaf110e47d1fbd6e Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Tue, 27 Nov 2018 10:59:08 -0800 Subject: [PATCH] Fix Bug 1504754 - Debug noscripts version of new tab page fail to load (#4560) --- aboutNewTabService.js | 11 +++++++---- bin/render-activity-stream-html.js | 2 -- test/xpcshell/test_AboutNewTabService.js | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/aboutNewTabService.js b/aboutNewTabService.js index 5976ef6a8..4ca97f166 100644 --- a/aboutNewTabService.js +++ b/aboutNewTabService.js @@ -108,6 +108,7 @@ AboutNewTabService.prototype = { case "nsPref:changed": if (data === PREF_SEPARATE_PRIVILEGED_CONTENT_PROCESS) { this._privilegedContentProcess = Services.prefs.getBoolPref(PREF_SEPARATE_PRIVILEGED_CONTENT_PROCESS); + this.updatePrerenderedPath(); this.notifyChange(); } else if (data === PREF_ACTIVITY_STREAM_PRERENDER_ENABLED) { this._activityStreamPrerender = Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_PRERENDER_ENABLED); @@ -229,9 +230,10 @@ AboutNewTabService.prototype = { * Figure out what path under prerendered to use based on current state. */ updatePrerenderedPath() { - // Debug files are specially packaged in a non-localized directory - this._activityStreamPath = `${this._activityStreamDebug ? "static" : - this.activityStreamLocale}/`; + // Debug files are specially packaged in a non-localized directory, but with + // dynamic script loading, localized debug is supported. + this._activityStreamPath = `${this._activityStreamDebug && + !this._privilegedContentProcess ? "static" : this.activityStreamLocale}/`; }, /* @@ -250,7 +252,8 @@ AboutNewTabService.prototype = { this._activityStreamPath, "activity-stream", this._activityStreamPrerender ? "-prerendered" : "", - this._activityStreamDebug ? "-debug" : "", + // Debug version loads dev scripts but noscripts separately loads scripts + this._activityStreamDebug && !this._privilegedContentProcess ? "-debug" : "", this._privilegedContentProcess ? "-noscripts" : "", ".html", ].join(""); diff --git a/bin/render-activity-stream-html.js b/bin/render-activity-stream-html.js index 8cabcef23..23a7c136f 100644 --- a/bin/render-activity-stream-html.js +++ b/bin/render-activity-stream-html.js @@ -152,10 +152,8 @@ function writeFiles(name, destPath, filesMap, {html, state}, options) { const STATIC_FILES = new Map([ ["activity-stream-debug.html", ({options}) => templateHTML(options)], - ["activity-stream-debug-noscripts.html", ({options}) => templateHTML(Object.assign({}, options, {noscripts: true}))], ["activity-stream-initial-state.js", ({state}) => templateJs("gActivityStreamPrerenderedState", "static", state)], ["activity-stream-prerendered-debug.html", ({html, options}) => templateHTML(options, html)], - ["activity-stream-prerendered-debug-noscripts.html", ({html, options}) => templateHTML(Object.assign({}, options, {noscripts: true}), html)], ]); const LOCALIZED_FILES = new Map([ diff --git a/test/xpcshell/test_AboutNewTabService.js b/test/xpcshell/test_AboutNewTabService.js index 9fc947ad9..1d577217c 100644 --- a/test/xpcshell/test_AboutNewTabService.js +++ b/test/xpcshell/test_AboutNewTabService.js @@ -42,9 +42,11 @@ function setExpectedUrlsWithScripts() { function setExpectedUrlsWithoutScripts() { ACTIVITY_STREAM_PRERENDER_URL = "resource://activity-stream/prerendered/en-US/activity-stream-prerendered-noscripts.html"; - ACTIVITY_STREAM_PRERENDER_DEBUG_URL = "resource://activity-stream/prerendered/static/activity-stream-prerendered-debug-noscripts.html"; ACTIVITY_STREAM_URL = "resource://activity-stream/prerendered/en-US/activity-stream-noscripts.html"; - ACTIVITY_STREAM_DEBUG_URL = "resource://activity-stream/prerendered/static/activity-stream-debug-noscripts.html"; + + // Debug urls are the same as non-debug because debug scripts load dynamically + ACTIVITY_STREAM_PRERENDER_DEBUG_URL = ACTIVITY_STREAM_PRERENDER_URL; + ACTIVITY_STREAM_DEBUG_URL = ACTIVITY_STREAM_URL; } function nextChangeNotificationPromise(aNewURL, testMessage) {