Bug 741979 - Don't require version numbers in the downloaded graphics driver blacklist. r=bjacob
authorJoe Drew <joe@drew.ca>
Fri, 04 May 2012 15:33:59 -0400
changeset 93279 f7cb2d403f33032a9f74662d996f8fe64be85fa2
parent 93278 e8d147cc71b0f1b7851b6490f41f2f312db91398
child 93280 da3bc1a730457f150877e1e84af3d6beabdb690b
push id22622
push userryanvm@gmail.com
push dateSun, 06 May 2012 03:08:51 +0000
treeherdermozilla-central@94ce5f33a9ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs741979
milestone15.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 741979 - Don't require version numbers in the downloaded graphics driver blacklist. r=bjacob
toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
widget/cocoa/GfxInfo.mm
widget/xpwidgets/GfxDriverInfo.cpp
widget/xpwidgets/GfxDriverInfo.h
widget/xpwidgets/GfxInfoBase.cpp
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
@@ -109,10 +109,46 @@
         <device>ghjk</device>
         <device>cvbn</device>
       </devices>
       <feature> DIRECT2D </feature>
       <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
       <driverVersion> 7 </driverVersion>
       <driverVersionComparator> GREATER_THAN_OR_EQUAL </driverVersionComparator>
     </gfxBlacklistEntry>
+    <gfxBlacklistEntry>
+      <os>WINNT 6.1</os>
+      <vendor>0xabcd</vendor>
+      <devices>
+        <device>0x6666</device>
+      </devices>
+      <feature> DIRECT2D </feature>
+      <featureStatus> BLOCKED_DEVICE </featureStatus>
+    </gfxBlacklistEntry>
+    <gfxBlacklistEntry>
+      <os>Darwin 9</os>
+      <vendor>0xabcd</vendor>
+      <devices>
+        <device>0x6666</device>
+      </devices>
+      <feature> DIRECT2D </feature>
+      <featureStatus> BLOCKED_DEVICE </featureStatus>
+    </gfxBlacklistEntry>
+    <gfxBlacklistEntry>
+      <os>Linux</os>
+      <vendor>0xabcd</vendor>
+      <devices>
+        <device>0x6666</device>
+      </devices>
+      <feature> DIRECT2D </feature>
+      <featureStatus> BLOCKED_DEVICE </featureStatus>
+    </gfxBlacklistEntry>
+    <gfxBlacklistEntry>
+      <os>Android</os>
+      <vendor>0xabcd</vendor>
+      <devices>
+        <device>0x6666</device>
+      </devices>
+      <feature> DIRECT2D </feature>
+      <featureStatus> BLOCKED_DEVICE </featureStatus>
+    </gfxBlacklistEntry>
   </gfxItems>
 </blocklist>
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
@@ -0,0 +1,89 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Test whether a machine which exactly matches the blacklist entry is
+// successfully blocked.
+// Uses test_gfxBlacklist.xml
+
+do_load_httpd_js();
+
+var gTestserver = null;
+
+function get_platform() {
+  var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+                             .getService(Components.interfaces.nsIXULRuntime);
+  return xulRuntime.OS;
+}
+
+function load_blocklist(file) {
+  Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file);
+  var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
+                  getService(Ci.nsITimerCallback);
+  blocklist.notify(null);
+}
+
+// Performs the initial setup
+function run_test() {
+  try {
+    var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+  } catch (e) {
+    do_test_finished();
+    return;
+  }
+
+  // We can't do anything if we can't spoof the stuff we need.
+  if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
+    do_test_finished();
+    return;
+  }
+
+  gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
+
+  gfxInfo.spoofVendorID("0xabcd");
+  gfxInfo.spoofDeviceID("0x6666");
+
+  // Spoof the OS version so it matches the test file.
+  switch (get_platform()) {
+    case "WINNT":
+      // Windows 7
+      gfxInfo.spoofOSVersion(0x60001);
+      break;
+    case "Linux":
+      break;
+    case "Darwin":
+      gfxInfo.spoofOSVersion(0x1050);
+      break;
+    case "Android":
+      break;
+  }
+
+  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
+  startupManager();
+
+  gTestserver = new nsHttpServer();
+  gTestserver.registerDirectory("/data/", do_get_file("data"));
+  gTestserver.start(4444);
+
+  do_test_pending();
+
+  function checkBlacklist()
+  {
+    var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
+    do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DEVICE);
+
+    // Make sure unrelated features aren't affected
+    status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
+    do_check_eq(status, Ci.nsIGfxInfo.FEATURE_NO_INFO);
+
+    gTestserver.stop(do_test_finished);
+  }
+
+  Services.obs.addObserver(function(aSubject, aTopic, aData) {
+    // If we wait until after we go through the event loop, gfxInfo is sure to
+    // have processed the gfxItems event.
+    do_execute_soon(checkBlacklist);
+  }, "blocklist-data-gfxItems", false);
+
+  load_blocklist("test_gfxBlacklist.xml");
+}
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -152,16 +152,17 @@ skip-if = os == "android"
 [test_getresource.js]
 [test_gfxBlacklist_Device.js]
 [test_gfxBlacklist_DriverNew.js]
 [test_gfxBlacklist_Equal_DriverNew.js]
 [test_gfxBlacklist_Equal_DriverOld.js]
 [test_gfxBlacklist_Equal_OK.js]
 [test_gfxBlacklist_GTE_DriverOld.js]
 [test_gfxBlacklist_GTE_OK.js]
+[test_gfxBlacklist_No_Comparison.js]
 [test_gfxBlacklist_OK.js]
 [test_gfxBlacklist_OS.js]
 [test_gfxBlacklist_Vendor.js]
 [test_gfxBlacklist_prefs.js]
 [test_hasbinarycomponents.js]
 [test_hotfix.js]
 [test_install.js]
 # Bug 676992: test consistently hangs on Android
--- a/widget/cocoa/GfxInfo.mm
+++ b/widget/cocoa/GfxInfo.mm
@@ -359,17 +359,17 @@ GfxInfo::AddCrashReportAnnotations()
   note.Append(narrowDeviceID);
   CrashReporter::AppendAppNotesToCrashReport(note);
 #endif
 }
 
 // We don't support checking driver versions on Mac.
 #define IMPLEMENT_MAC_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn) \
   APPEND_TO_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn,           \
-                             DRIVER_UNKNOWN_COMPARISON, V(0,0,0,0), "")
+                             DRIVER_COMPARISON_IGNORED, V(0,0,0,0), "")
 
 
 const nsTArray<GfxDriverInfo>&
 GfxInfo::GetGfxDriverInfo()
 {
   if (!mDriverInfo->Length()) {
     IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL,
       (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices,
--- a/widget/xpwidgets/GfxDriverInfo.cpp
+++ b/widget/xpwidgets/GfxDriverInfo.cpp
@@ -49,17 +49,17 @@ nsAString* GfxDriverInfo::mDeviceVendors
 
 GfxDriverInfo::GfxDriverInfo()
   : mOperatingSystem(DRIVER_OS_UNKNOWN),
     mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)),
     mDevices(allDevices),
     mDeleteDevices(false),
     mFeature(allFeatures),
     mFeatureStatus(nsIGfxInfo::FEATURE_NO_INFO),
-    mComparisonOp(DRIVER_UNKNOWN_COMPARISON),
+    mComparisonOp(DRIVER_COMPARISON_IGNORED),
     mDriverVersion(0),
     mDriverVersionMax(0),
     mSuggestedVersion(nsnull)
 {}
 
 GfxDriverInfo::GfxDriverInfo(OperatingSystem os, nsAString& vendor,
                              GfxDeviceFamily* devices,
                              PRInt32 feature, PRInt32 featureStatus,
--- a/widget/xpwidgets/GfxDriverInfo.h
+++ b/widget/xpwidgets/GfxDriverInfo.h
@@ -71,17 +71,17 @@ enum VersionComparisonOp {
   DRIVER_LESS_THAN_OR_EQUAL,    // driver <= version
   DRIVER_GREATER_THAN,          // driver >  version
   DRIVER_GREATER_THAN_OR_EQUAL, // driver >= version
   DRIVER_EQUAL,                 // driver == version
   DRIVER_NOT_EQUAL,             // driver != version
   DRIVER_BETWEEN_EXCLUSIVE,     // driver > version && driver < versionMax
   DRIVER_BETWEEN_INCLUSIVE,     // driver >= version && driver <= versionMax
   DRIVER_BETWEEN_INCLUSIVE_START, // driver >= version && driver < versionMax
-  DRIVER_UNKNOWN_COMPARISON
+  DRIVER_COMPARISON_IGNORED
 };
 
 enum DeviceFamily {
   IntelGMA500,
   IntelGMA900,
   IntelGMA950,
   IntelGMA3150,
   IntelGMAX3000,
--- a/widget/xpwidgets/GfxInfoBase.cpp
+++ b/widget/xpwidgets/GfxInfoBase.cpp
@@ -337,17 +337,17 @@ BlacklistComparatorToComparisonOp(const 
     return DRIVER_NOT_EQUAL;
   else if (op == NS_LITERAL_STRING("BETWEEN_EXCLUSIVE"))
     return DRIVER_BETWEEN_EXCLUSIVE;
   else if (op == NS_LITERAL_STRING("BETWEEN_INCLUSIVE"))
     return DRIVER_BETWEEN_INCLUSIVE;
   else if (op == NS_LITERAL_STRING("BETWEEN_INCLUSIVE_START"))
     return DRIVER_BETWEEN_INCLUSIVE_START;
 
-  return DRIVER_UNKNOWN_COMPARISON;
+  return DRIVER_COMPARISON_IGNORED;
 }
 
 // Arbitrarily returns the first |tagname| child of |element|.
 static bool
 BlacklistNodeGetChildByName(nsIDOMElement *element,
                             const nsAString& tagname,
                             nsIDOMNode** firstchild)
 {
@@ -627,16 +627,20 @@ GfxInfoBase::FindBlocklistedDeviceInList
       match = driverVersion > info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax;
       break;
     case DRIVER_BETWEEN_INCLUSIVE:
       match = driverVersion >= info[i].mDriverVersion && driverVersion <= info[i].mDriverVersionMax;
       break;
     case DRIVER_BETWEEN_INCLUSIVE_START:
       match = driverVersion >= info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax;
       break;
+    case DRIVER_COMPARISON_IGNORED:
+      // We don't have a comparison op, so we match everything.
+      match = true;
+      break;
     default:
       NS_WARNING("Bogus op in GfxDriverInfo");
       break;
     }
 #else
     // We don't care what driver version it was. We only check OS version and if
     // the device matches.
     match = true;