|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Test whether a machine which differs only on OS version, but otherwise |
|
6 // exactly matches the blacklist entry, is not blocked. |
|
7 // Uses test_gfxBlacklist.xml |
|
8 |
|
9 Components.utils.import("resource://testing-common/httpd.js"); |
|
10 |
|
11 var gTestserver = new HttpServer(); |
|
12 gTestserver.start(-1); |
|
13 gPort = gTestserver.identity.primaryPort; |
|
14 mapFile("/data/test_gfxBlacklist.xml", gTestserver); |
|
15 |
|
16 function get_platform() { |
|
17 var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] |
|
18 .getService(Components.interfaces.nsIXULRuntime); |
|
19 return xulRuntime.OS; |
|
20 } |
|
21 |
|
22 function load_blocklist(file) { |
|
23 Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + |
|
24 gPort + "/data/" + file); |
|
25 var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. |
|
26 getService(Ci.nsITimerCallback); |
|
27 blocklist.notify(null); |
|
28 } |
|
29 |
|
30 // Performs the initial setup |
|
31 function run_test() { |
|
32 try { |
|
33 var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); |
|
34 } catch (e) { |
|
35 do_test_finished(); |
|
36 return; |
|
37 } |
|
38 |
|
39 // We can't do anything if we can't spoof the stuff we need. |
|
40 if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) { |
|
41 do_test_finished(); |
|
42 return; |
|
43 } |
|
44 |
|
45 gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); |
|
46 |
|
47 // Set the vendor/device ID, etc, to match the test file. |
|
48 switch (get_platform()) { |
|
49 case "WINNT": |
|
50 gfxInfo.spoofVendorID("0xabcd"); |
|
51 gfxInfo.spoofDeviceID("0x1234"); |
|
52 gfxInfo.spoofDriverVersion("8.52.322.2201"); |
|
53 // Windows Vista |
|
54 gfxInfo.spoofOSVersion(0x60000); |
|
55 break; |
|
56 case "Linux": |
|
57 // We don't have any OS versions on Linux, just "Linux". |
|
58 do_test_finished(); |
|
59 return; |
|
60 case "Darwin": |
|
61 gfxInfo.spoofVendorID("0xabcd"); |
|
62 gfxInfo.spoofDeviceID("0x1234"); |
|
63 // Snow Leopard |
|
64 gfxInfo.spoofOSVersion(0x1060); |
|
65 break; |
|
66 case "Android": |
|
67 // On Android, the driver version is used as the OS version (because |
|
68 // there's so many of them). |
|
69 do_test_finished(); |
|
70 return; |
|
71 } |
|
72 |
|
73 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); |
|
74 startupManager(); |
|
75 |
|
76 do_test_pending(); |
|
77 |
|
78 function checkBlacklist() |
|
79 { |
|
80 var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D); |
|
81 do_check_eq(status, Ci.nsIGfxInfo.FEATURE_NO_INFO); |
|
82 |
|
83 status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS); |
|
84 do_check_eq(status, Ci.nsIGfxInfo.FEATURE_NO_INFO); |
|
85 |
|
86 gTestserver.stop(do_test_finished); |
|
87 } |
|
88 |
|
89 Services.obs.addObserver(function(aSubject, aTopic, aData) { |
|
90 // If we wait until after we go through the event loop, gfxInfo is sure to |
|
91 // have processed the gfxItems event. |
|
92 do_execute_soon(checkBlacklist); |
|
93 }, "blocklist-data-gfxItems", false); |
|
94 |
|
95 load_blocklist("test_gfxBlacklist.xml"); |
|
96 } |