Bug 1163038 - More tests to pass by running instead of catching an exception. r=kats

--HG--
extra : rebase_source : 2c561c39037c4ba75b6931ba14553d2f5ebb537a
This commit is contained in:
Milan Sreckovic 2015-07-21 11:42:25 -04:00
parent 8cb39f819f
commit 9a2da7a4da
13 changed files with 102 additions and 127 deletions

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which differs only on device ID, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -60,7 +58,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x9876");
gfxInfo.spoofOSVersion(0x1050);
gfxInfo.spoofOSVersion(0x1060);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a new-enough driver bypasses the blacklist, even if the rest of
// the attributes match the blacklist entry.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which is newer than the equal
// blacklist entry is allowed.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which is older than the equal
// blacklist entry is correctly allowed.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which exactly matches the equal
// blacklist entry is successfully blocked.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which is lower than the greater-than-or-equal
// blacklist entry is allowed.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which exactly matches the greater-than-or-equal
// blacklist entry is successfully blocked.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which exactly matches the blacklist entry is
// successfully blocked.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -56,7 +54,7 @@ function run_test() {
case "Linux":
break;
case "Darwin":
gfxInfo.spoofOSVersion(0x1050);
gfxInfo.spoofOSVersion(0x1060);
break;
case "Android":
break;

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which differs only on OS version, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -60,8 +58,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
// Snow Leopard
gfxInfo.spoofOSVersion(0x1060);
gfxInfo.spoofOSVersion(0x1070);
break;
case "Android":
// On Android, the driver version is used as the OS version (because

View File

@ -2,18 +2,22 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether new OS versions are matched properly.
// Uses test_gfxBlacklist_OS.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -27,12 +31,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -92,5 +91,5 @@ function run_test() {
do_execute_soon(checkBlacklist);
}, "blocklist-data-gfxItems", false);
load_blocklist("test_gfxBlacklist_OS.xml");
load_blocklist("test_gfxBlacklist_OSVersion.xml");
}

View File

@ -2,19 +2,23 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether blocklists specifying new OSeswcorrectly don't block if driver
// versions are appropriately up-to-date.
// Uses test_gfxBlacklist_OS.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -28,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -59,8 +58,7 @@ function run_test() {
do_test_finished();
return;
case "Darwin":
// Mountain Lion
gfxInfo.spoofOSVersion(0x1080);
gfxInfo.spoofOSVersion(0x1090);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
@ -93,5 +91,5 @@ function run_test() {
do_execute_soon(checkBlacklist);
}, "blocklist-data-gfxItems", false);
load_blocklist("test_gfxBlacklist_OS.xml");
load_blocklist("test_gfxBlacklist_OSVersion.xml");
}

View File

@ -2,19 +2,23 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether old OS versions are not matched when the blacklist contains
// only new OS versions.
// Uses test_gfxBlacklist_OS.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -28,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -93,5 +92,5 @@ function run_test() {
do_execute_soon(checkBlacklist);
}, "blocklist-data-gfxItems", false);
load_blocklist("test_gfxBlacklist_OS.xml");
load_blocklist("test_gfxBlacklist_OSVersion.xml");
}

View File

@ -2,11 +2,14 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This should eventually be moved to head_addons.js
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
// Test whether a machine which differs only on vendor, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
Components.utils.import("resource://testing-common/httpd.js");
Cu.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@ -14,8 +17,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime);
return xulRuntime.OS;
}
@ -29,12 +32,7 @@ function load_blocklist(file) {
// 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;
}
var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@ -60,7 +58,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xdcba");
gfxInfo.spoofDeviceID("0x1234");
gfxInfo.spoofOSVersion(0x1050);
gfxInfo.spoofOSVersion(0x1060);
break;
case "Android":
gfxInfo.spoofVendorID("dcba");