Bug 1245256 - Updated tests to work with new Widevine functionality. r=spohl,a=ritu
authorKirk Steuber <ksteuber@mozilla.com>
Tue, 01 Mar 2016 14:42:01 -0800
changeset 324050 8f64c830bbba37cd355dff20a38111e02125903d
parent 324049 23bbe17ceb0d0dc71fba8ae233a9be30ea239b2e
child 324051 9e203da8fe185ba020cae1e439e4d112437b88bf
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, ritu
bugs1245256
milestone47.0a2
Bug 1245256 - Updated tests to work with new Widevine functionality. r=spohl,a=ritu MozReview-Commit-ID: GasIh1GUxX7
toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
--- a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
@@ -16,17 +16,18 @@ var gIsEnUsLocale;
 
 var gMockAddons = [];
 
 for (let plugin of GMPScope.GMP_PLUGINS) {
   let mockAddon = Object.freeze({
       id: plugin.id,
       isValid: true,
       isInstalled: false,
-      isEME: plugin.id.indexOf("gmp-eme-") == 0 ? true : false,
+      isEME: (plugin.id == "gmp-widevinecdm" ||
+              plugin.id.indexOf("gmp-eme-") == 0) ? true : false,
   });
   gMockAddons.push(mockAddon);
 }
 
 var gInstalledAddonId = "";
 var gInstallDeferred = null;
 var gPrefs = Services.prefs;
 var getKey = GMPScope.GMPPrefs.getPrefKey;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
@@ -23,17 +23,18 @@ for (let plugin of GMPScope.GMP_PLUGINS)
       isValid: true,
       isInstalled: false,
       nameId: plugin.name,
       descriptionId: plugin.description,
       missingKey: plugin.missingKey,
       missingFilesKey: plugin.missingFilesKey,
   });
   gMockAddons.set(mockAddon.id, mockAddon);
-  if (mockAddon.id.indexOf("gmp-eme-") == 0) {
+  if (mockAddon.id == "gmp-widevinecdm" ||
+      mockAddon.id.indexOf("gmp-eme-") == 0) {
     gMockEmeAddons.set(mockAddon.id, mockAddon);
   }
 }
 
 var gInstalledAddonId = "";
 var gPrefs = Services.prefs;
 var gGetKey = GMPScope.GMPPrefs.getPrefKey;
 
@@ -231,17 +232,21 @@ function createMockPluginFilesIfNeeded(a
       f.create(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
     }
   }
 
   let id = aPluginId.substring(4);
   let libName = AppConstants.DLL_PREFIX + id + AppConstants.DLL_SUFFIX;
 
   createFile(libName);
-  createFile(id + ".info");
+  if (aPluginId == "gmp-widevinecdm") {
+    createFile("manifest.json");
+  } else {
+    createFile(id + ".info");
+  }
   if (aPluginId == "gmp-eme-adobe")
     createFile(id + ".voucher");
 }
 
 // Array.includes() is only in Nightly channel, so polyfill so we don't fail
 // on other branches.
 if (![].includes) {
   Array.prototype.includes = function(element) {
@@ -302,36 +307,42 @@ add_task(function* test_pluginRegistrati
                        TEST_VERSION);
     clearPaths();
     yield promiseRestartManager();
     Assert.equal(addedPaths.indexOf(file.path), -1);
     Assert.deepEqual(removedPaths, [file.path]);
 
     // Test that the GMPProvider tried to report via telemetry that the
     // addon's lib files are missing.
-    Assert.strictEqual(reportedKeys[addon.missingKey], true);
-    Assert.strictEqual(reportedKeys[addon.missingFilesKey],
-                       addon.missingFilesKey != "VIDEO_ADOBE_GMP_MISSING_FILES"
-                       ? (1+2) : (1+2+4));
+    if (addon.missingKey) {
+      Assert.strictEqual(reportedKeys[addon.missingKey], true);
+    }
+    if (addon.missingFilesKey) {
+      Assert.strictEqual(reportedKeys[addon.missingFilesKey],
+                         addon.missingFilesKey != "VIDEO_ADOBE_GMP_MISSING_FILES"
+                         ? (1+2) : (1+2+4));
+    }
     reportedKeys = {};
 
     // Create dummy GMP library/info files, and test that plugin registration
     // succeeds during startup, now that we've added GMP info/lib files.
     createMockPluginFilesIfNeeded(file, addon.id);
 
     gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
                        TEST_VERSION);
     clearPaths();
     yield promiseRestartManager();
     Assert.notEqual(addedPaths.indexOf(file.path), -1);
     Assert.deepEqual(removedPaths, []);
 
     // Test that the GMPProvider tried to report via telemetry that the
     // addon's lib files are NOT missing.
-    Assert.strictEqual(reportedKeys[addon.missingFilesKey], 0);
+    if (addon.missingFilesKey) {
+      Assert.strictEqual(reportedKeys[addon.missingFilesKey], 0);
+    }
 
     // Setting the ABI to something invalid should cause plugin to be removed at startup.
     clearPaths();
     gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ABI, addon.id), "invalid-ABI");
     yield promiseRestartManager();
     Assert.equal(addedPaths.indexOf(file.path), -1);
     Assert.deepEqual(removedPaths, [file.path]);