Bug 1347947 - Move static checking browser mochitests to their own folder, r=Gijs.
authorFlorian Quèze <florian@queze.net>
Thu, 16 Mar 2017 19:26:01 +0100
changeset 398636 b5df0025c79dc5cce54216194ab9ba8ddb38d222
parent 398635 34554df9f50cb34482838c1200fea11cb87b9095
child 398637 6e8fab91c7b5330502facd1317d1ddcb824c96b6
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1347947
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1347947 - Move static checking browser mochitests to their own folder, r=Gijs.
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_misused_characters_in_strings.js
browser/base/content/test/general/browser_parsable_css.js
browser/base/content/test/general/browser_parsable_script.js
browser/base/content/test/general/bug1262648_string_with_newlines.dtd
browser/base/content/test/general/parsingTestHelpers.jsm
browser/base/content/test/static/browser.ini
browser/base/content/test/static/browser_misused_characters_in_strings.js
browser/base/content/test/static/browser_parsable_css.js
browser/base/content/test/static/browser_parsable_script.js
browser/base/content/test/static/bug1262648_string_with_newlines.dtd
browser/base/content/test/static/dummy_page.html
browser/base/content/test/static/head.js
browser/base/moz.build
devtools/client/framework/test/browser.ini
tools/lint/eslint/modules.json
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -12,17 +12,16 @@ support-files =
   browser_bug678392-2.html
   browser_bug970746.xhtml
   browser_fxa_web_channel.html
   browser_registerProtocolHandler_notification.html
   browser_star_hsts.sjs
   browser_tab_dragdrop2_frame1.xul
   browser_web_channel.html
   browser_web_channel_iframe.html
-  bug1262648_string_with_newlines.dtd
   bug592338.html
   bug792517-2.html
   bug792517.html
   bug792517.sjs
   bug839103.css
   clipboard_pastefile.html
   contextmenu_common.js
   ctxmenu-image.png
@@ -46,17 +45,16 @@ support-files =
   head.js
   healthreport_pingData.js
   healthreport_testRemoteCommands.html
   moz.png
   navigating_window_with_download.html
   offlineQuotaNotification.cacheManifest
   offlineQuotaNotification.html
   page_style_sample.html
-  parsingTestHelpers.jsm
   pinning_headers.sjs
   ssl_error_reports.sjs
   popup_blocker.html
   print_postdata.sjs
   searchSuggestionEngine.sjs
   searchSuggestionEngine.xml
   searchSuggestionEngine2.xml
   subtst_contextmenu.html
@@ -262,32 +260,27 @@ skip-if = e10s # Bug 863514 - no gesture
 [browser_keywordSearch_postData.js]
 [browser_lastAccessedTab.js]
 skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bug 969405)
 [browser_menuButtonFitts.js]
 skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (bug 969376)
 [browser_middleMouse_noJSPaste.js]
 subsuite = clipboard
 [browser_minimize.js]
-[browser_misused_characters_in_strings.js]
 [browser_modifiedclick_inherit_principal.js]
 [browser_new_http_window_opened_from_file_tab.js]
 [browser_offlineQuotaNotification.js]
 skip-if = os == "linux" && !debug # bug 1304273
 [browser_feed_discovery.js]
 support-files = feed_discovery.html
 [browser_gZipOfflineChild.js]
 support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^
 [browser_overflowScroll.js]
 [browser_page_style_menu.js]
 [browser_page_style_menu_update.js]
-[browser_parsable_css.js]
-skip-if = debug # no point in running on both opt and debug, and will likely intermittently timeout on debug
-[browser_parsable_script.js]
-skip-if = asan || (os == 'linux' && !debug && (bits == 32)) # disabled on asan because of timeouts, and bug 1172468 for the linux 32-bit pgo issue.
 [browser_permissions.js]
 support-files =
   permissions.html
 [browser_pinnedTabs.js]
 [browser_plainTextLinks.js]
 [browser_popupUI.js]
 [browser_popup_blocker.js]
 skip-if = (os == 'linux') || (e10s && debug) # Frequent bug 1081925 and bug 1125520 failures
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/static/browser.ini
@@ -0,0 +1,13 @@
+[DEFAULT]
+support-files =
+  head.js
+
+[browser_misused_characters_in_strings.js]
+support-files =
+  bug1262648_string_with_newlines.dtd
+[browser_parsable_css.js]
+support-files =
+  dummy_page.html
+skip-if = debug # no point in running on both opt and debug, and will likely intermittently timeout on debug
+[browser_parsable_script.js]
+skip-if = asan || (os == 'linux' && !debug && (bits == 32)) # disabled on asan because of timeouts, and bug 1172468 for the linux 32-bit pgo issue.
rename from browser/base/content/test/general/browser_misused_characters_in_strings.js
rename to browser/base/content/test/static/browser_misused_characters_in_strings.js
--- a/browser/base/content/test/general/browser_misused_characters_in_strings.js
+++ b/browser/base/content/test/static/browser_misused_characters_in_strings.js
@@ -102,19 +102,16 @@ let gWhitelist = [{
     type: "double-quote"
   }, {
     file: "aboutNetworking.dtd",
     key: "aboutNetworking.logTutorial",
     type: "single-quote"
   }
 ];
 
-var moduleLocation = gTestPath.replace(/\/[^\/]*$/i, "/parsingTestHelpers.jsm");
-var {generateURIsFromDirTree} = Cu.import(moduleLocation, {});
-
 /**
  * Check if an error should be ignored due to matching one of the whitelist
  * objects defined in gWhitelist.
  *
  * @param filepath The URI spec of the locale file
  * @param key The key of the entity that is being checked
  * @param type The type of error that has been found
  * @return true if the error should be ignored, false otherwise.
@@ -130,16 +127,17 @@ function ignoredError(filepath, key, typ
     }
   }
   return false;
 }
 
 function fetchFile(uri) {
   return new Promise((resolve, reject) => {
     let xhr = new XMLHttpRequest();
+    xhr.responseType = "text";
     xhr.open("GET", uri, true);
     xhr.onreadystatechange = function() {
       if (this.readyState != this.DONE) {
         return;
       }
       try {
         resolve(this.responseText);
       } catch (ex) {
rename from browser/base/content/test/general/browser_parsable_css.js
rename to browser/base/content/test/static/browser_parsable_css.js
--- a/browser/base/content/test/general/browser_parsable_css.js
+++ b/browser/base/content/test/static/browser_parsable_css.js
@@ -62,19 +62,16 @@ let allowedImageReferences = [
   {file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png",
    from: "chrome://devtools/skin/toolbox.css",
    isFromDevTools: true},
   {file: "chrome://devtools/skin/images/dock-bottom-maximize@2x.png",
    from: "chrome://devtools/skin/toolbox.css",
    isFromDevTools: true},
 ];
 
-var moduleLocation = gTestPath.replace(/\/[^\/]*$/i, "/parsingTestHelpers.jsm");
-var {generateURIsFromDirTree} = Cu.import(moduleLocation, {});
-
 // Add suffix to stylesheets' URI so that we always load them here and
 // have them parsed. Add a random number so that even if we run this
 // test multiple times, it would be unlikely to affect each other.
 const kPathSuffix = "?always-parse-css-" + Math.random();
 
 /**
  * Check if an error should be ignored due to matching one of the whitelist
  * objects defined in whitelist
@@ -295,35 +292,35 @@ add_task(function* checkAllTheCSS() {
   // filter out either the devtools paths or the non-devtools paths:
   let isDevtools = SimpleTest.harnessParameters.subsuite == "devtools";
   let devtoolsPathBits = ["webide", "devtools"];
   uris = uris.filter(uri => isDevtools == devtoolsPathBits.some(path => uri.spec.includes(path)));
 
   for (let uri of uris) {
     let linkEl = doc.createElement("link");
     linkEl.setAttribute("rel", "stylesheet");
-    let promiseForThisSpec = Promise.defer();
-    let onLoad = (e) => {
-      processCSSRules(linkEl.sheet);
-      promiseForThisSpec.resolve();
-      linkEl.removeEventListener("load", onLoad);
-      linkEl.removeEventListener("error", onError);
-    };
-    let onError = (e) => {
-      ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!");
-      promiseForThisSpec.resolve();
-      linkEl.removeEventListener("load", onLoad);
-      linkEl.removeEventListener("error", onError);
-    };
-    linkEl.addEventListener("load", onLoad);
-    linkEl.addEventListener("error", onError);
-    linkEl.setAttribute("type", "text/css");
-    let chromeUri = convertToChromeUri(uri);
-    linkEl.setAttribute("href", chromeUri.spec + kPathSuffix);
-    allPromises.push(promiseForThisSpec.promise);
+    allPromises.push(new Promise(resolve => {
+      let onLoad = (e) => {
+        processCSSRules(linkEl.sheet);
+        resolve();
+        linkEl.removeEventListener("load", onLoad);
+        linkEl.removeEventListener("error", onError);
+      };
+      let onError = (e) => {
+        ok(false, "Loading " + linkEl.getAttribute("href") + " threw an error!");
+        resolve();
+        linkEl.removeEventListener("load", onLoad);
+        linkEl.removeEventListener("error", onError);
+      };
+      linkEl.addEventListener("load", onLoad);
+      linkEl.addEventListener("error", onError);
+      linkEl.setAttribute("type", "text/css");
+      let chromeUri = convertToChromeUri(uri);
+      linkEl.setAttribute("href", chromeUri.spec + kPathSuffix);
+    }));
     doc.head.appendChild(linkEl);
   }
 
   // Wait for all the files to have actually loaded:
   yield Promise.all(allPromises);
 
   // Check if all the files referenced from CSS actually exist.
   for (let [image, references] of imageURIsToReferencesMap) {
rename from browser/base/content/test/general/browser_parsable_script.js
rename to browser/base/content/test/static/browser_parsable_script.js
--- a/browser/base/content/test/general/browser_parsable_script.js
+++ b/browser/base/content/test/static/browser_parsable_script.js
@@ -5,20 +5,16 @@
  * detect newly occurring issues in shipping JS. It is a list of regexes
  * matching files which have errors:
  */
 const kWhitelist = new Set([
   /defaults\/profile\/prefs.js$/,
   /browser\/content\/browser\/places\/controller.js$/,
 ]);
 
-
-var moduleLocation = gTestPath.replace(/\/[^\/]*$/i, "/parsingTestHelpers.jsm");
-var {generateURIsFromDirTree} = Cu.import(moduleLocation, {});
-
 // Normally we would use reflect.jsm to get Reflect.parse. However, if
 // we do that, then all the AST data is allocated in reflect.jsm's
 // zone. That exposes a bug in our GC. The GC collects reflect.jsm's
 // zone but not the zone in which our test code lives (since no new
 // data is being allocated in it). The cross-compartment wrappers in
 // our zone that point to the AST data never get collected, and so the
 // AST data itself is never collected. We need to GC both zones at
 // once to fix the problem.
@@ -45,17 +41,17 @@ function parsePromise(uri) {
   let promise = new Promise((resolve, reject) => {
     let xhr = new XMLHttpRequest();
     xhr.open("GET", uri, true);
     xhr.onreadystatechange = function() {
       if (this.readyState == this.DONE) {
         let scriptText = this.responseText;
         try {
           info("Checking " + uri);
-          Reflect.parse(scriptText);
+          Reflect.parse(scriptText, {source: uri});
           resolve(true);
         } catch (ex) {
           let errorMsg = "Script error reading " + uri + ": " + ex;
           ok(false, errorMsg);
           resolve(false);
         }
       }
     };
@@ -90,17 +86,17 @@ add_task(function* checkAllTheJS() {
     requestLongerTimeout(30);
   }
 
   let uris;
   // If an absolute URI is specified on the command line, use it immediately.
   if (parseValue && parseValue.includes(":")) {
     uris = [NetUtil.newURI(parseValue)];
   } else {
-    let appDir = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
+    let appDir = Services.dirsvc.get("GreD", Ci.nsIFile);
     // This asynchronously produces a list of URLs (sadly, mostly sync on our
     // test infrastructure because it runs against jarfiles there, and
     // our zipreader APIs are all sync)
     let startTimeMs = Date.now();
     info("Collecting URIs");
     uris = yield generateURIsFromDirTree(appDir, [".js", ".jsm"]);
     info("Collected URIs in " + (Date.now() - startTimeMs) + "ms");
 
rename from browser/base/content/test/general/bug1262648_string_with_newlines.dtd
rename to browser/base/content/test/static/bug1262648_string_with_newlines.dtd
copy from browser/base/content/test/general/dummy_page.html
copy to browser/base/content/test/static/dummy_page.html
rename from browser/base/content/test/general/parsingTestHelpers.jsm
rename to browser/base/content/test/static/head.js
--- a/browser/base/content/test/general/parsingTestHelpers.jsm
+++ b/browser/base/content/test/static/head.js
@@ -1,15 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-this.EXPORTED_SYMBOLS = ["generateURIsFromDirTree"];
-
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 /* Shorthand constructors to construct an nsI(Local)File and zip reader: */
 const LocalFile = new Components.Constructor("@mozilla.org/file/local;1", Ci.nsIFile, "initWithPath");
 const ZipReader = new Components.Constructor("@mozilla.org/libjar/zip-reader;1", "nsIZipReader", "open");
 
 
 Cu.import("resource://gre/modules/Services.jsm");
@@ -122,10 +120,8 @@ function* generateEntriesFromJarFile(jar
     if (entry.startsWith("jsloader") || entry.startsWith("jssubloader")) {
       continue;
     }
     let entryURISpec = "jar:" + kURIStart + "!/" + entry;
     yield Services.io.newURI(entryURISpec);
   }
   zr.close();
 }
-
-
--- a/browser/base/moz.build
+++ b/browser/base/moz.build
@@ -21,16 +21,17 @@ BROWSER_CHROME_MANIFESTS += [
     'content/test/general/browser.ini',
     'content/test/newtab/browser.ini',
     'content/test/pageinfo/browser.ini',
     'content/test/plugins/browser.ini',
     'content/test/popupNotifications/browser.ini',
     'content/test/referrer/browser.ini',
     'content/test/siteIdentity/browser.ini',
     'content/test/social/browser.ini',
+    'content/test/static/browser.ini',
     'content/test/tabcrashed/browser.ini',
     'content/test/tabPrompts/browser.ini',
     'content/test/tabs/browser.ini',
     'content/test/urlbar/browser.ini',
     'content/test/webextensions/browser.ini',
     'content/test/webrtc/browser.ini',
 ]
 
--- a/devtools/client/framework/test/browser.ini
+++ b/devtools/client/framework/test/browser.ini
@@ -90,9 +90,9 @@ skip-if = e10s # Bug 1069044 - destroyIn
 [browser_toolbox_window_reload_target.js]
 [browser_toolbox_window_shortcuts.js]
 skip-if = os == "mac" && os_version == "10.8" || os == "win" && os_version == "5.1" # Bug 851129 - Re-enable browser_toolbox_window_shortcuts.js test after leaks are fixed
 [browser_toolbox_window_title_changes.js]
 [browser_toolbox_window_title_frame_select.js]
 [browser_toolbox_zoom.js]
 [browser_two_tabs.js]
 # We want this test to run for mochitest-dt as well, so we include it here:
-[../../../../browser/base/content/test/general/browser_parsable_css.js]
+[../../../../browser/base/content/test/static/browser_parsable_css.js]
--- a/tools/lint/eslint/modules.json
+++ b/tools/lint/eslint/modules.json
@@ -159,17 +159,16 @@
   "osfile_unix_allthreads.jsm": ["declareFFI", "libc", "Error", "AbstractInfo", "AbstractEntry", "Type", "POS_START", "POS_CURRENT", "POS_END"],
   "osfile_win_allthreads.jsm": ["declareFFI", "libc", "Error", "AbstractInfo", "AbstractEntry", "Type", "POS_START", "POS_CURRENT", "POS_END"],
   "ospath_unix.jsm": ["basename", "dirname", "join", "normalize", "split", "toFileURI", "fromFileURI"],
   "ospath_win.jsm": ["basename", "dirname", "join", "normalize", "split", "winGetDrive", "winIsAbsolute", "toFileURI", "fromFileURI"],
   "OutputGenerator.jsm": ["UtteranceGenerator", "BrailleGenerator"],
   "PageMenu.jsm": ["PageMenuParent", "PageMenuChild"],
   "PageThumbs.jsm": ["PageThumbs", "PageThumbsStorage"],
   "Parser.jsm": ["Parser", "ParserHelpers", "SyntaxTreeVisitor"],
-  "parsingTestHelpers.jsm": ["generateURIsFromDirTree"],
   "passwords.js": ["PasswordEngine", "LoginRec", "PasswordValidator"],
   "passwords.jsm": ["Password", "DumpPasswords"],
   "PdfJsNetwork.jsm": ["NetworkManager"],
   "PhoneNumberMetaData.jsm": ["PHONE_NUMBER_META_DATA"],
   "PlacesUtils.jsm": ["PlacesUtils", "PlacesAggregatedTransaction", "PlacesCreateFolderTransaction", "PlacesCreateBookmarkTransaction", "PlacesCreateSeparatorTransaction", "PlacesCreateLivemarkTransaction", "PlacesMoveItemTransaction", "PlacesRemoveItemTransaction", "PlacesEditItemTitleTransaction", "PlacesEditBookmarkURITransaction", "PlacesEditLivemarkFeedURITransaction", "PlacesEditLivemarkSiteURITransaction", "PlacesSetItemAnnotationTransaction", "PlacesSetPageAnnotationTransaction", "PlacesEditBookmarkKeywordTransaction", "PlacesEditBookmarkPostDataTransaction", "PlacesEditItemDateAddedTransaction", "PlacesEditItemLastModifiedTransaction", "PlacesSortFolderByNameTransaction", "PlacesTagURITransaction", "PlacesUntagURITransaction"],
   "PluginProvider.jsm": [],
   "PointerAdapter.jsm": ["PointerRelay", "PointerAdapter"],
   "policies.js": ["ErrorHandler", "SyncScheduler"],