Commit 043ebf19 authored by Doug Sherk's avatar Doug Sherk
Browse files

Bug 710103: Update XPCShell tests for GfxInfo blocklisting r=joe a=mbrubeck

parent cf38d958
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -54,5 +54,65 @@
      <driverVersion> 8.52.322.1111 </driverVersion>
      <driverVersionComparator> EQUAL </driverVersionComparator>
    </gfxBlacklistEntry>
    <gfxBlacklistEntry>
      <os>Darwin 9</os>
      <vendor>0xabcd</vendor>
      <devices>
        <device>0x2783</device>
        <device>0x1234</device>
        <device>0x2782</device>
      </devices>
      <feature> DIRECT2D </feature>
      <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
    </gfxBlacklistEntry>
    <gfxBlacklistEntry>
      <os>Linux</os>
      <vendor>0xabcd</vendor>
      <devices>
        <device>0x2783</device>
        <device>0x1234</device>
        <device>0x2782</device>
      </devices>
      <feature> DIRECT2D </feature>
      <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
    </gfxBlacklistEntry>
    <gfxBlacklistEntry>
      <os>Android</os>
      <vendor>abcd</vendor>
      <devices>
        <device>wxyz</device>
        <device>asdf</device>
        <device>erty</device>
      </devices>
      <feature> DIRECT2D </feature>
      <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
      <driverVersion> 5 </driverVersion>
      <driverVersionComparator> LESS_THAN_OR_EQUAL </driverVersionComparator>
    </gfxBlacklistEntry>
    <gfxBlacklistEntry>
      <os>Android</os>
      <vendor>dcdc</vendor>
      <devices>
        <device>uiop</device>
        <device>vbnm</device>
        <device>hjkl</device>
      </devices>
      <feature> DIRECT2D </feature>
      <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
      <driverVersion> 5 </driverVersion>
      <driverVersionComparator> EQUAL </driverVersionComparator>
    </gfxBlacklistEntry>
    <gfxBlacklistEntry>
      <os>Android</os>
      <vendor>abab</vendor>
      <devices>
        <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>
  </gfxItems>
</blocklist>
+0 −72
Original line number Diff line number Diff line
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// Make sure that a blacklist entry with an OS of "All" matches Windows 7, as
// long as the rest of the blacklist matches it.
// Uses test_gfxBlacklist_AllOS.xml

do_load_httpd_js();

var gTestserver = null;

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);

  // Set the vendor/device ID, etc, to match the test file.
  gfxInfo.spoofVendorID(0xabcd);
  gfxInfo.spoofDeviceID(0x1234);
  gfxInfo.spoofDriverVersion("8.52.322.2201");
  // Windows 7
  gfxInfo.spoofOSVersion(0x60001);

  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_DRIVER_VERSION);

    // 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_AllOS.xml");
}
+0 −72
Original line number Diff line number Diff line
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// Make sure that a blacklist entry with an OS of "All" matches Windows Vista,
// as long as the rest of the blacklist matches it.
// Uses test_gfxBlacklist_AllOS.xml

do_load_httpd_js();

var gTestserver = null;

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);

  // Set the vendor/device ID, etc, to match the test file.
  gfxInfo.spoofVendorID(0xabcd);
  gfxInfo.spoofDeviceID(0x1234);
  gfxInfo.spoofDriverVersion("8.52.322.2201");
  // Windows Vista
  gfxInfo.spoofOSVersion(0x60000);

  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_DRIVER_VERSION);

    // 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_AllOS.xml");
}
+29 −5
Original line number Diff line number Diff line
@@ -10,6 +10,12 @@ 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"].
@@ -35,11 +41,29 @@ function run_test() {
  gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);

  // Set the vendor/device ID, etc, to match the test file.
  gfxInfo.spoofVendorID(0xabcd);
  gfxInfo.spoofDeviceID(0x9876);
  switch (get_platform()) {
    case "WINNT":
      gfxInfo.spoofVendorID("0xabcd");
      gfxInfo.spoofDeviceID("0x9876");
      gfxInfo.spoofDriverVersion("8.52.322.2201");
      // Windows 7
      gfxInfo.spoofOSVersion(0x60001);
      break;
    case "Linux":
      gfxInfo.spoofVendorID("0xabcd");
      gfxInfo.spoofDeviceID("0x9876");
      break;
    case "Darwin":
      gfxInfo.spoofVendorID("0xabcd");
      gfxInfo.spoofDeviceID("0x9876");
      gfxInfo.spoofOSVersion(0x1050);
      break;
    case "Android":
      gfxInfo.spoofVendorID("abcd");
      gfxInfo.spoofDeviceID("aabb");
      gfxInfo.spoofDriverVersion("5");
      break;
  }

  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
  startupManager();
+28 −5
Original line number Diff line number Diff line
@@ -10,6 +10,12 @@ 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"].
@@ -35,11 +41,28 @@ function run_test() {
  gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);

  // Set the vendor/device ID, etc, to match the test file.
  gfxInfo.spoofVendorID(0xabcd);
  gfxInfo.spoofDeviceID(0x1234);
  switch (get_platform()) {
    case "WINNT":
      gfxInfo.spoofVendorID("0xabcd");
      gfxInfo.spoofDeviceID("0x1234");
      gfxInfo.spoofDriverVersion("8.52.322.2202");
      // Windows 7
      gfxInfo.spoofOSVersion(0x60001);
      break;
    case "Linux":
      // We don't support driver versions on Linux.
      do_test_finished();
      return;
    case "Darwin":
      // We don't support driver versions on Darwin.
      do_test_finished();
      return;
    case "Android":
      gfxInfo.spoofVendorID("abcd");
      gfxInfo.spoofDeviceID("wxyz");
      gfxInfo.spoofDriverVersion("6");
      break;
  }

  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
  startupManager();
Loading