1 DriverInfo = (function () {
2 // ---------------------------------------------------------------------------
6 window.console.log("Info: " + str);
9 // ---------------------------------------------------------------------------
10 // OS and driver identification
11 // Stolen from dom/canvas/test/webgl/test_webgl_conformance_test_suite.html
12 function detectDriverInfo() {
13 var canvas = document.createElement("canvas");
20 gl = canvas.getContext("experimental-webgl");
24 info("Failed to create WebGL context for querying driver info.");
28 var ext = gl.getExtension("WEBGL_debug_renderer_info");
30 throw "WEBGL_debug_renderer_info not available";
33 var webglRenderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
37 function detectOSInfo() {
40 if (navigator.platform.indexOf("Win") == 0) {
43 var versionMatch = /Windows NT (\d+.\d+)/.exec(navigator.userAgent);
44 version = versionMatch ? parseFloat(versionMatch[1]) : null;
45 // Version 6.0 is Vista, 6.1 is 7.
46 } else if (navigator.platform.indexOf("Mac") == 0) {
49 var versionMatch = /Mac OS X (\d+.\d+)/.exec(navigator.userAgent);
50 version = versionMatch ? parseFloat(versionMatch[1]) : null;
51 } else if (navigator.appVersion.includes("Android")) {
55 // From layout/tools/reftest/reftest.js:
56 version = SpecialPowers.Services.sysinfo.getProperty("version");
58 info("No SpecialPowers: can't query android version");
60 } else if (navigator.platform.indexOf("Linux") == 0) {
61 // Must be checked after android, as android also has a 'Linux' platform string.
79 ANDROID_X86_EMULATOR: "android x86 emulator",
84 var kOSVersion = null;
85 var kRawDriver = null;
89 [kOS, kOSVersion] = detectOSInfo();
91 // Generally just fails when we don't have SpecialPowers.
95 kRawDriver = detectDriverInfo();
97 if (kRawDriver.includes("llvmpipe")) {
98 kDriver = DRIVER.MESA;
99 } else if (kRawDriver.includes("Android Emulator")) {
100 kDriver = DRIVER.ANDROID_X86_EMULATOR;
101 } else if (kRawDriver.includes("ANGLE")) {
102 kDriver = DRIVER.ANGLE;
103 } else if (kRawDriver.includes("NVIDIA")) {
104 kDriver = DRIVER.NVIDIA;
105 } else if (kRawDriver.includes("Intel")) {
106 kDriver = DRIVER.INTEL;
109 // detectDriverInfo is fallible where WebGL fails.
112 function dump(line_out_func) {
114 "[DriverInfo] userAgent: " + navigator.userAgent,
115 "[DriverInfo] kRawDriver: " + kRawDriver,
116 "[DriverInfo] kDriver: " + kDriver,
117 "[DriverInfo] kOS: " + kOS,
118 "[DriverInfo] kOSVersion: " + kOSVersion,
120 lines.forEach(line_out_func);
123 dump(x => console.log(x));