Bug 1188015 - Tile Bottom Bar: Automatic Color [r=emtwo]
authorMaxim Zhilyaev <mzhilyaev@mozilla.com>
Fri, 04 Sep 2015 06:34:20 -0700
changeset 260765 9d35eca4bc3a8d021c07298f804273ef6c6661c9
parent 260764 69bd898471ce3a95f4ff24fd494d7ff8ed275782
child 260854 a70692ababcacb80a8c52536e610597f9c41446a
push id15044
push usermzhilyaev@mozilla.com
push dateFri, 04 Sep 2015 13:34:54 +0000
treeherderfx-team@9d35eca4bc3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemtwo
bugs1188015
milestone43.0a1
Bug 1188015 - Tile Bottom Bar: Automatic Color [r=emtwo]
browser/base/content/newtab/sites.js
browser/base/content/test/newtab/browser.ini
browser/base/content/test/newtab/browser_newtab_1188015.js
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -167,19 +167,24 @@ Site.prototype = {
     let title = enhanced && enhanced.title ? enhanced.title :
                 this.link.type == "history" ? this.link.baseDomain :
                 this.title;
     let tooltip = (this.title == url ? this.title : this.title + "\n" + url);
 
     let link = this._querySelector(".newtab-link");
     link.setAttribute("title", tooltip);
     link.setAttribute("href", url);
-    this._querySelector(".newtab-title").textContent = title;
     this.node.setAttribute("type", this.link.type);
 
+    let titleNode = this._querySelector(".newtab-title");
+    titleNode.textContent = title;
+    if (this.link.titleBgColor) {
+      titleNode.style.backgroundColor = this.link.titleBgColor;
+    }
+
     if (this.link.targetedSite) {
       if (this.node.getAttribute("type") != "sponsored") {
         this._querySelector(".newtab-sponsored").textContent =
           newTabString("suggested.tag");
       }
 
       this.node.setAttribute("suggested", true);
       let explanation = this._getSuggestedTileExplanation();
--- a/browser/base/content/test/newtab/browser.ini
+++ b/browser/base/content/test/newtab/browser.ini
@@ -45,8 +45,9 @@ support-files =
   ../general/searchSuggestionEngine.sjs
 [browser_newtab_sponsored_icon_click.js]
 [browser_newtab_undo.js]
 [browser_newtab_unpin.js]
 [browser_newtab_update.js]
 [browser_newtab_bug1145428.js]
 [browser_newtab_bug1178586.js]
 [browser_newtab_bug1194895.js]
+[browser_newtab_1188015.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_1188015.js
@@ -0,0 +1,28 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+const PRELOAD_PREF = "browser.newtab.preload";
+
+gDirectorySource = "data:application/json," + JSON.stringify({
+  "directory": [{
+    url: "http://example1.com/",
+    enhancedImageURI: "data:image/png;base64,helloWORLD2",
+    title: "title1",
+    type: "affiliate",
+    titleBgColor: "green"
+  }]
+});
+
+function runTests() {
+  registerCleanupFunction(() => {
+    Services.prefs.clearUserPref(PRELOAD_PREF);
+  });
+
+  Services.prefs.setBoolPref(PRELOAD_PREF, false);
+
+  // Make the page have a directory link
+  yield setLinks([]);
+  yield addNewTabPageTab();
+  let titleNode = getCell(0).node.querySelector(".newtab-title");
+  is(titleNode.style.backgroundColor, "green", "title bg color is green");
+}