Bug 1143745 - Update the way Firefox reads directoryLinks.json sent from the server for the tiles v3 endpoint. r=adw, a=sylvestre
authorMarina Samuel <msamuel@mozilla.com>
Thu, 26 Mar 2015 17:17:59 -0400
changeset 258195 745269d59b33
parent 258194 65f2aa5f2dd7
child 258196 60f350a6b8b8
push id4619
push useredilee@gmail.com
push date2015-04-02 05:50 +0000
treeherdermozilla-beta@daf8a9291a9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, sylvestre
bugs1143745
milestone38.0
Bug 1143745 - Update the way Firefox reads directoryLinks.json sent from the server for the tiles v3 endpoint. r=adw, a=sylvestre
browser/base/content/newtab/newTab.css
browser/base/content/newtab/sites.js
browser/base/content/test/newtab/browser_newtab_enhanced.js
browser/base/content/test/newtab/browser_newtab_reportLinkAction.js
browser/modules/DirectoryLinksProvider.jsm
browser/modules/test/xpcshell/test_DirectoryLinksProvider.js
--- a/browser/base/content/newtab/newTab.css
+++ b/browser/base/content/newtab/newTab.css
@@ -257,17 +257,17 @@ input[type=button] {
   left: 0;
   right: auto;
 }
 
 .newtab-site:-moz-any([type=enhanced], [type=sponsored]) .newtab-sponsored {
   display: block;
 }
 
-.newtab-site[type=suggested] .newtab-suggested {
+.newtab-site[suggested] .newtab-suggested {
   display: table;
 }
 
 .sponsored-explain,
 .sponsored-explain a,
 .suggested-explain,
 .suggested-explain a {
   color: white;
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -127,16 +127,17 @@ Site.prototype = {
 
     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);
 
     if (this.link.targetedSite) {
+      this.node.setAttribute("suggested", true);
       let targetedSite = `<strong> ${this.link.targetedSite} </strong>`;
       this._querySelector(".newtab-suggested").innerHTML =
         `<div class='newtab-suggested-bounds'>Suggested for ${targetedSite} visitors</div>`;
     }
 
     if (this.isPinned())
       this._updateAttributes(true);
     // Capture the page if the thumbnail is missing, which will cause page.js
@@ -243,17 +244,17 @@ Site.prototype = {
     }
     else {
       let explain = document.createElementNS(HTML_NAMESPACE, "div");
       explain.className = explanationTextClass.slice(1); // Slice off the first character, '.'
       this.node.appendChild(explain);
 
       let link = '<a href="' + TILES_EXPLAIN_LINK + '">' +
                  newTabString("learn.link") + "</a>";
-      let type = this.node.getAttribute("type");
+      let type = this.node.getAttribute("suggested") ? "suggested" : this.node.getAttribute("type");
       let icon = '<input type="button" class="newtab-control newtab-' +
                  (type == "enhanced" ? "customize" : "control-block") + '"/>';
 
       if (type == "suggested") {
         explain.innerHTML = `This site is suggested to you by Mozilla. You can remove it at any time by clicking the ${icon} button. ${link}`;
       } else {
         explain.innerHTML = newTabString(type + ".explain", [icon, link]);
       }
--- a/browser/base/content/test/newtab/browser_newtab_enhanced.js
+++ b/browser/base/content/test/newtab/browser_newtab_enhanced.js
@@ -1,15 +1,15 @@
 /* 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({
-  "en-US": [{
+  "directory": [{
     url: "http://example.com/",
     enhancedImageURI: "data:image/png;base64,helloWORLD",
     title: "title",
     type: "organic"
   }]
 });
 
 function runTests() {
--- a/browser/base/content/test/newtab/browser_newtab_reportLinkAction.js
+++ b/browser/base/content/test/newtab/browser_newtab_reportLinkAction.js
@@ -1,15 +1,15 @@
 /* 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({
-  "en-US": [{
+  "directory": [{
     url: "http://example.com/organic",
     type: "organic"
   }, {
     url: "http://localhost/sponsored",
     type: "sponsored"
   }]
 });
 
--- a/browser/modules/DirectoryLinksProvider.jsm
+++ b/browser/modules/DirectoryLinksProvider.jsm
@@ -197,17 +197,17 @@ let DirectoryLinksProvider = {
   _removePrefsObserver: function DirectoryLinksProvider_removeObserver() {
     for (let pref in this._observedPrefs) {
       let prefName = this._observedPrefs[pref];
       Services.prefs.removeObserver(prefName, this);
     }
   },
 
   _cacheRelatedLinks: function(link) {
-    for (let relatedSite of link.suggested) {
+    for (let relatedSite of link.frecent_sites) {
       let relatedMap = this._relatedLinks.get(relatedSite) || new Map();
       relatedMap.set(link.url, link);
       this._relatedLinks.set(relatedSite, relatedMap);
     }
   },
 
   _fetchAndCacheLinks: function DirectoryLinksProvider_fetchAndCacheLinks(uri) {
     // Replace with the same display locale used for selecting links data
@@ -288,35 +288,37 @@ let DirectoryLinksProvider = {
     if ((Date.now() - this._lastDownloadMS) > this._downloadIntervalMS) {
       return true;
     }
     return false;
   },
 
   /**
    * Reads directory links file and parses its content
-   * @return a promise resolved to valid list of links or [] if read or parse fails
+   * @return a promise resolved to an object with keys 'directory' and 'suggested',
+   *         each containing a valid list of links,
+   *         or {'directory': [], 'suggested': []} if read or parse fails.
    */
   _readDirectoryLinksFile: function DirectoryLinksProvider_readDirectoryLinksFile() {
+    let emptyOutput = {directory: [], suggested: []};
     return OS.File.read(this._directoryFilePath).then(binaryData => {
       let output;
       try {
-        let locale = this.locale;
         let json = gTextDecoder.decode(binaryData);
-        let list = JSON.parse(json);
-        output = list[locale];
+        let linksObj = JSON.parse(json);
+        output = {directory: linksObj.directory || [], suggested: linksObj.suggested || []};
       }
       catch (e) {
         Cu.reportError(e);
       }
-      return output || [];
+      return output || emptyOutput;
     },
     error => {
       Cu.reportError(error);
-      return [];
+      return emptyOutput;
     });
   },
 
   /**
    * Report some action on a newtab page (view, click)
    * @param sites Array of sites shown on newtab page
    * @param action String of the behavior to report
    * @param triggeringSiteIndex optional Int index of the site triggering action
@@ -410,39 +412,44 @@ let DirectoryLinksProvider = {
    * @param aCallback The function that the array of links is passed to.
    */
   getLinks: function DirectoryLinksProvider_getLinks(aCallback) {
     this._readDirectoryLinksFile().then(rawLinks => {
       // Reset the cache of related tiles and enhanced images for this new set of links
       this._enhancedLinks.clear();
       this._relatedLinks.clear();
 
-      let links = [];
-      rawLinks.filter(link => {
+      let validityFilter = function(link) {
         // Make sure the link url is allowed and images too if they exist
         return this.isURLAllowed(link.url, ALLOWED_LINK_SCHEMES) &&
                this.isURLAllowed(link.imageURI, ALLOWED_IMAGE_SCHEMES) &&
                this.isURLAllowed(link.enhancedImageURI, ALLOWED_IMAGE_SCHEMES);
-      }).forEach((link, position) => {
+      }.bind(this);
+
+      let setCommonProperties = function(link, length, position) {
         // Stash the enhanced image for the site
         if (link.enhancedImageURI) {
           this._enhancedLinks.set(NewTabUtils.extractSite(link.url), link);
         }
-        link.lastVisitDate = rawLinks.length - position;
+        link.lastVisitDate = length - position;
+      }.bind(this);
+
+      rawLinks.suggested.filter(validityFilter).forEach((link, position) => {
+        setCommonProperties(link, rawLinks.suggested.length, position);
 
         // We cache related tiles here but do not push any of them in the links list yet.
         // The decision for which related tile to include will be made separately.
-        if ("suggested" == link.type) {
-          this._cacheRelatedLinks(link);
-          return;
-        }
+        this._cacheRelatedLinks(link);
+      });
+
+      return rawLinks.directory.filter(validityFilter).map((link, position) => {
+        setCommonProperties(link, rawLinks.directory.length, position);
         link.frecency = DIRECTORY_FRECENCY;
-        links.push(link);
+        return link;
       });
-      return links;
     }).catch(ex => {
       Cu.reportError(ex);
       return [];
     }).then(links => {
       aCallback(links);
       this._populatePlacesLinks();
     });
   },
@@ -537,22 +544,22 @@ let DirectoryLinksProvider = {
       return;
     }
 
     // Delete the current related tile, if one exists.
     let initialLength = sortedLinks.length;
     this.maxNumLinks = initialLength;
     if (initialLength) {
       let mostFrecentLink = sortedLinks[0];
-      if ("suggested" == mostFrecentLink.type) {
+      if (mostFrecentLink.targetedSite) {
         this._callObservers("onLinkChanged", {
           url: mostFrecentLink.url,
           frecency: 0,
           lastVisitDate: mostFrecentLink.lastVisitDate,
-          type: "suggested",
+          type: mostFrecentLink.type,
         }, 0, true);
       }
     }
 
     if (this._topSitesWithRelatedLinks.size == 0) {
       // There are no potential related links we can show.
       return;
     }
@@ -584,17 +591,17 @@ let DirectoryLinksProvider = {
     let chosenRelatedLink = flattenedLinks[relatedIndex];
 
     // Show the new directory tile.
     this._callObservers("onLinkChanged", {
       url: chosenRelatedLink.url,
       title: chosenRelatedLink.title,
       frecency: RELATED_FRECENCY,
       lastVisitDate: chosenRelatedLink.lastVisitDate,
-      type: "suggested",
+      type: chosenRelatedLink.type,
 
       // Choose the first site a user has visited as the target. In the future,
       // this should be the site with the highest frecency. However, we currently
       // store frecency by URL not by site.
       targetedSite: targetedSites.get(chosenRelatedLink.url).length ?
         targetedSites.get(chosenRelatedLink.url)[0] : null
     });
     return chosenRelatedLink;
--- a/browser/modules/test/xpcshell/test_DirectoryLinksProvider.js
+++ b/browser/modules/test/xpcshell/test_DirectoryLinksProvider.js
@@ -21,17 +21,17 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils",
   "resource://gre/modules/NewTabUtils.jsm");
 
 do_get_profile();
 
 const DIRECTORY_LINKS_FILE = "directoryLinks.json";
 const DIRECTORY_FRECENCY = 1000;
-const kURLData = {"en-US": [{"url":"http://example.com","title":"LocalSource"}]};
+const kURLData = {"directory": [{"url":"http://example.com","title":"LocalSource"}]};
 const kTestURL = 'data:application/json,' + JSON.stringify(kURLData);
 
 // DirectoryLinksProvider preferences
 const kLocalePref = DirectoryLinksProvider._observedPrefs.prefSelectedLocale;
 const kSourceUrlPref = DirectoryLinksProvider._observedPrefs.linksURL;
 const kPingUrlPref = "browser.newtabpage.directory.ping";
 const kNewtabEnhancedPref = "browser.newtabpage.enhanced";
 
@@ -48,51 +48,51 @@ const kPingUrl = kBaseUrl + kPingPath;
 
 // app/profile/firefox.js are not avaialble in xpcshell: hence, preset them
 Services.prefs.setCharPref(kLocalePref, "en-US");
 Services.prefs.setCharPref(kSourceUrlPref, kTestURL);
 Services.prefs.setCharPref(kPingUrlPref, kPingUrl);
 Services.prefs.setBoolPref(kNewtabEnhancedPref, true);
 
 const kHttpHandlerData = {};
-kHttpHandlerData[kExamplePath] = {"en-US": [{"url":"http://example.com","title":"RemoteSource"}]};
+kHttpHandlerData[kExamplePath] = {"directory": [{"url":"http://example.com","title":"RemoteSource"}]};
 
 const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
                               "nsIBinaryInputStream",
                               "setInputStream");
 
 let gLastRequestPath;
 
 let relatedTile1 = {
   url: "http://turbotax.com",
-  type: "suggested",
-  lastVisitDate: 4,
-  suggested: [
+  type: "affiliate",
+  lastVisitDate: 3,
+  frecent_sites: [
     "taxact.com",
     "hrblock.com",
     "1040.com",
     "taxslayer.com"
   ]
 };
 let relatedTile2 = {
   url: "http://irs.gov",
-  type: "suggested",
-  lastVisitDate: 3,
-  suggested: [
+  type: "affiliate",
+  lastVisitDate: 2,
+  frecent_sites: [
     "taxact.com",
     "hrblock.com",
     "freetaxusa.com",
     "taxslayer.com"
   ]
 };
 let relatedTile3 = {
   url: "http://hrblock.com",
-  type: "suggested",
-  lastVisitDate: 2,
-  suggested: [
+  type: "affiliate",
+  lastVisitDate: 1,
+  frecent_sites: [
     "taxact.com",
     "freetaxusa.com",
     "1040.com",
     "taxslayer.com"
   ]
 };
 let someOtherSite = {url: "http://someothersite.com", title: "Not_A_Related_Site"};
 
@@ -213,17 +213,17 @@ function run_test() {
     Services.prefs.clearUserPref(kNewtabEnhancedPref);
   });
 }
 
 add_task(function test_updateRelatedTile() {
   let topSites = ["site0.com", "1040.com", "site2.com", "hrblock.com", "site4.com", "freetaxusa.com", "site6.com"];
 
   // Initial setup
-  let data = {"en-US": [relatedTile1, relatedTile2, relatedTile3, someOtherSite]};
+  let data = {"suggested": [relatedTile1, relatedTile2, relatedTile3], "directory": [someOtherSite]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
 
   let testObserver = new TestFirstRun();
   DirectoryLinksProvider.addObserver(testObserver);
 
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
   let links = yield fetchData();
 
@@ -243,31 +243,31 @@ add_task(function test_updateRelatedTile
     this.promise = new Promise(resolve => {
       this.onLinkChanged = (directoryLinksProvider, link) => {
         links.unshift(link);
         let possibleLinks = [relatedTile1.url, relatedTile2.url, relatedTile3.url];
 
         isIdentical([...DirectoryLinksProvider._topSitesWithRelatedLinks], ["hrblock.com", "1040.com", "freetaxusa.com"]);
         do_check_true(possibleLinks.indexOf(link.url) > -1);
         do_check_eq(link.frecency, Infinity);
-        do_check_eq(link.type, "suggested");
+        do_check_eq(link.type, "affiliate");
         resolve();
       };
     });
   }
 
   function TestChangingRelatedTile() {
     this.count = 0;
     this.promise = new Promise(resolve => {
       this.onLinkChanged = (directoryLinksProvider, link) => {
         this.count++;
         let possibleLinks = [relatedTile1.url, relatedTile2.url, relatedTile3.url];
 
         do_check_true(possibleLinks.indexOf(link.url) > -1);
-        do_check_eq(link.type, "suggested");
+        do_check_eq(link.type, "affiliate");
         do_check_true(this.count <= 2);
 
         if (this.count == 1) {
           // The removed related link is the one we added initially.
           do_check_eq(link.url, links.shift().url);
           do_check_eq(link.frecency, 0);
         } else {
           links.unshift(link);
@@ -280,17 +280,17 @@ add_task(function test_updateRelatedTile
   }
 
   function TestRemovingRelatedTile() {
     this.count = 0;
     this.promise = new Promise(resolve => {
       this.onLinkChanged = (directoryLinksProvider, link) => {
         this.count++;
 
-        do_check_eq(link.type, "suggested");
+        do_check_eq(link.type, "affiliate");
         do_check_eq(this.count, 1);
         do_check_eq(link.frecency, 0);
         do_check_eq(link.url, links.shift().url);
         isIdentical([...DirectoryLinksProvider._topSitesWithRelatedLinks], []);
         resolve();
       }
     });
   }
@@ -335,17 +335,17 @@ add_task(function test_updateRelatedTile
 
   // Cleanup
   yield promiseCleanDirectoryLinksProvider();
   NewTabUtils.isTopPlacesSite = origIsTopPlacesSite;
   NewTabUtils.getProviderLinks = origGetProviderLinks;
 });
 
 add_task(function test_relatedLinksMap() {
-  let data = {"en-US": [relatedTile1, relatedTile2, relatedTile3, someOtherSite]};
+  let data = {"suggested": [relatedTile1, relatedTile2, relatedTile3], "directory": [someOtherSite]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
 
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
   let links = yield fetchData();
 
   // Ensure the related tiles were not considered directory tiles.
   do_check_eq(links.length, 1);
   let expected_data = [{url: "http://someothersite.com", title: "Not_A_Related_Site", frecency: DIRECTORY_FRECENCY, lastVisitDate: 1}];
@@ -381,17 +381,17 @@ add_task(function test_topSitesWithRelat
   let origGetProviderLinks = NewTabUtils.getProviderLinks;
   NewTabUtils.getProviderLinks = function(provider) {
     return [];
   }
 
   // We start off with no top sites with related links.
   do_check_eq(DirectoryLinksProvider._topSitesWithRelatedLinks.size, 0);
 
-  let data = {"en-US": [relatedTile1, relatedTile2, relatedTile3, someOtherSite]};
+  let data = {"suggested": [relatedTile1, relatedTile2, relatedTile3], "directory": [someOtherSite]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
 
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
   let links = yield fetchData();
 
   // Check we've populated related links as expected.
   do_check_eq(DirectoryLinksProvider._relatedLinks.size, 5);
 
@@ -600,49 +600,16 @@ add_task(function test_DirectoryLinksPro
 
   yield testObserver.deferred.promise;
   DirectoryLinksProvider._removeObservers();
   do_check_eq(DirectoryLinksProvider._observers.size, 0);
 
   yield promiseCleanDirectoryLinksProvider();
 });
 
-add_task(function test_linksURL_locale() {
-  let data = {
-    "en-US": [{url: "http://example.com", title: "US"}],
-    "zh-CN": [
-              {url: "http://example.net", title: "CN"},
-              {url:"http://example.net/2", title: "CN2"}
-    ],
-  };
-  let dataURI = 'data:application/json,' + JSON.stringify(data);
-
-  yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
-
-  let links;
-  let expected_data;
-
-  links = yield fetchData();
-  do_check_eq(links.length, 1);
-  expected_data = [{url: "http://example.com", title: "US", frecency: DIRECTORY_FRECENCY, lastVisitDate: 1}];
-  isIdentical(links, expected_data);
-
-  yield promiseDirectoryDownloadOnPrefChange("general.useragent.locale", "zh-CN");
-
-  links = yield fetchData();
-  do_check_eq(links.length, 2)
-  expected_data = [
-    {url: "http://example.net", title: "CN", frecency: DIRECTORY_FRECENCY, lastVisitDate: 2},
-    {url: "http://example.net/2", title: "CN2", frecency: DIRECTORY_FRECENCY, lastVisitDate: 1}
-  ];
-  isIdentical(links, expected_data);
-
-  yield promiseCleanDirectoryLinksProvider();
-});
-
 add_task(function test_DirectoryLinksProvider__prefObserver_url() {
   yield promiseSetupDirectoryLinksProvider({linksURL: kTestURL});
 
   let links = yield fetchData();
   do_check_eq(links.length, 1);
   let expectedData =  [{url: "http://example.com", title: "LocalSource", frecency: DIRECTORY_FRECENCY, lastVisitDate: 1}];
   isIdentical(links, expectedData);
 
@@ -662,18 +629,23 @@ add_task(function test_DirectoryLinksPro
   yield promiseDirectoryDownloadOnPrefChange(kSourceUrlPref, exampleUrl + " ");
   // we now should see empty links
   newLinks = yield fetchData();
   isIdentical(newLinks, []);
 
   yield promiseCleanDirectoryLinksProvider();
 });
 
-add_task(function test_DirectoryLinksProvider_getLinks_noLocaleData() {
-  yield promiseSetupDirectoryLinksProvider({locale: 'zh-CN'});
+add_task(function test_DirectoryLinksProvider_getLinks_noDirectoryData() {
+  let data = {
+    "directory": [],
+  };
+  let dataURI = 'data:application/json,' + JSON.stringify(data);
+  yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
+
   let links = yield fetchData();
   do_check_eq(links.length, 0);
   yield promiseCleanDirectoryLinksProvider();
 });
 
 add_task(function test_DirectoryLinksProvider_getLinks_badData() {
   let data = {
     "en-US": {
@@ -799,80 +771,80 @@ add_task(function test_DirectoryLinksPro
   yield OS.File.writeAtomic(directoryLinksFilePath, '{"en-US":');
   let data = yield fetchData();
   isIdentical(data, []);
 
   yield promiseCleanDirectoryLinksProvider();
 });
 
 add_task(function test_DirectoryLinksProvider_getAllowedLinks() {
-  let data = {"en-US": [
+  let data = {"directory": [
     {url: "ftp://example.com"},
     {url: "http://example.net"},
     {url: "javascript:5"},
     {url: "https://example.com"},
     {url: "httpJUNKjavascript:42"},
     {url: "data:text/plain,hi"},
     {url: "http/bork:eh"},
   ]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
 
   let links = yield fetchData();
   do_check_eq(links.length, 2);
 
   // The only remaining url should be http and https
-  do_check_eq(links[0].url, data["en-US"][1].url);
-  do_check_eq(links[1].url, data["en-US"][3].url);
+  do_check_eq(links[0].url, data["directory"][1].url);
+  do_check_eq(links[1].url, data["directory"][3].url);
 });
 
 add_task(function test_DirectoryLinksProvider_getAllowedImages() {
-  let data = {"en-US": [
+  let data = {"directory": [
     {url: "http://example.com", imageURI: "ftp://example.com"},
     {url: "http://example.com", imageURI: "http://example.net"},
     {url: "http://example.com", imageURI: "javascript:5"},
     {url: "http://example.com", imageURI: "https://example.com"},
     {url: "http://example.com", imageURI: "httpJUNKjavascript:42"},
     {url: "http://example.com", imageURI: "data:text/plain,hi"},
     {url: "http://example.com", imageURI: "http/bork:eh"},
   ]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
 
   let links = yield fetchData();
   do_check_eq(links.length, 2);
 
   // The only remaining images should be https and data
-  do_check_eq(links[0].imageURI, data["en-US"][3].imageURI);
-  do_check_eq(links[1].imageURI, data["en-US"][5].imageURI);
+  do_check_eq(links[0].imageURI, data["directory"][3].imageURI);
+  do_check_eq(links[1].imageURI, data["directory"][5].imageURI);
 });
 
 add_task(function test_DirectoryLinksProvider_getAllowedEnhancedImages() {
-  let data = {"en-US": [
+  let data = {"directory": [
     {url: "http://example.com", enhancedImageURI: "ftp://example.com"},
     {url: "http://example.com", enhancedImageURI: "http://example.net"},
     {url: "http://example.com", enhancedImageURI: "javascript:5"},
     {url: "http://example.com", enhancedImageURI: "https://example.com"},
     {url: "http://example.com", enhancedImageURI: "httpJUNKjavascript:42"},
     {url: "http://example.com", enhancedImageURI: "data:text/plain,hi"},
     {url: "http://example.com", enhancedImageURI: "http/bork:eh"},
   ]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
 
   let links = yield fetchData();
   do_check_eq(links.length, 2);
 
   // The only remaining enhancedImages should be http and https and data
-  do_check_eq(links[0].enhancedImageURI, data["en-US"][3].enhancedImageURI);
-  do_check_eq(links[1].enhancedImageURI, data["en-US"][5].enhancedImageURI);
+  do_check_eq(links[0].enhancedImageURI, data["directory"][3].enhancedImageURI);
+  do_check_eq(links[1].enhancedImageURI, data["directory"][5].enhancedImageURI);
 });
 
 add_task(function test_DirectoryLinksProvider_getEnhancedLink() {
-  let data = {"en-US": [
+  let data = {"directory": [
     {url: "http://example.net", enhancedImageURI: "data:,net1"},
     {url: "http://example.com", enhancedImageURI: "data:,com1"},
     {url: "http://example.com", enhancedImageURI: "data:,com2"},
   ]};
   let dataURI = 'data:application/json,' + JSON.stringify(data);
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
 
   let links = yield fetchData();
@@ -902,17 +874,17 @@ add_task(function test_DirectoryLinksPro
 
   // Undefined for not enhanced
   checkEnhanced("http://sub.example.net/", undefined);
   checkEnhanced("http://example.org", undefined);
   checkEnhanced("http://localhost", undefined);
   checkEnhanced("http://127.0.0.1", undefined);
 
   // Make sure old data is not cached
-  data = {"en-US": [
+  data = {"directory": [
     {url: "http://example.com", enhancedImageURI: "data:,fresh"},
   ]};
   dataURI = 'data:application/json,' + JSON.stringify(data);
   yield promiseSetupDirectoryLinksProvider({linksURL: dataURI});
   links = yield fetchData();
   do_check_eq(links.length, 1);
   checkEnhanced("http://example.net", undefined);
   checkEnhanced("http://example.com", "data:,fresh");