2015-06-17 01:49:26 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2015-06-17 01:49:26 +03:00
|
|
|
|
2015-07-08 23:00:17 +03:00
|
|
|
const FRAME_SCRIPT_URL = "chrome://gfxsanity/content/gfxFrameScript.js";
|
|
|
|
|
2020-10-28 04:12:57 +03:00
|
|
|
const TEST_DISABLED_PREF = "media.sanity-test.disabled";
|
2017-09-06 16:42:46 +03:00
|
|
|
const PAGE_WIDTH = 160;
|
|
|
|
const PAGE_HEIGHT = 234;
|
2017-09-07 20:19:35 +03:00
|
|
|
const LEFT_EDGE = 8;
|
|
|
|
const TOP_EDGE = 8;
|
|
|
|
const CANVAS_WIDTH = 32;
|
|
|
|
const CANVAS_HEIGHT = 64;
|
2017-09-07 20:36:20 +03:00
|
|
|
// If those values are ever changed, make sure to update
|
|
|
|
// WMFVideoMFTManager::CanUseDXVA accordingly.
|
|
|
|
const VIDEO_WIDTH = 132;
|
|
|
|
const VIDEO_HEIGHT = 132;
|
2016-11-11 01:48:04 +03:00
|
|
|
const DRIVER_PREF = "sanity-test.driver-version";
|
|
|
|
const DEVICE_PREF = "sanity-test.device-id";
|
|
|
|
const VERSION_PREF = "sanity-test.version";
|
2017-07-11 05:30:52 +03:00
|
|
|
const ADVANCED_LAYERS_PREF = "sanity-test.advanced-layers";
|
2020-02-19 02:19:14 +03:00
|
|
|
const WEBRENDER_DISABLED_PREF = "sanity-test.webrender.force-disabled";
|
2016-11-11 01:48:04 +03:00
|
|
|
const DISABLE_VIDEO_PREF = "media.hardware-video-decoding.failed";
|
|
|
|
const RUNNING_PREF = "sanity-test.running";
|
|
|
|
const TIMEOUT_SEC = 20;
|
2015-06-17 01:49:26 +03:00
|
|
|
|
2017-09-08 20:21:18 +03:00
|
|
|
const AL_ENABLED_PREF = "layers.mlgpu.enabled";
|
2017-07-11 05:30:52 +03:00
|
|
|
const AL_TEST_FAILED_PREF = "layers.mlgpu.sanity-test-failed";
|
2020-02-19 02:19:14 +03:00
|
|
|
const WR_DISABLED_PREF = "gfx.webrender.force-disabled";
|
2017-07-11 05:30:52 +03:00
|
|
|
|
2015-06-17 01:49:26 +03:00
|
|
|
// GRAPHICS_SANITY_TEST histogram enumeration values
|
2016-11-11 01:48:04 +03:00
|
|
|
const TEST_PASSED = 0;
|
|
|
|
const TEST_FAILED_RENDER = 1;
|
|
|
|
const TEST_FAILED_VIDEO = 2;
|
|
|
|
const TEST_CRASHED = 3;
|
|
|
|
const TEST_TIMEOUT = 4;
|
2015-06-17 01:49:26 +03:00
|
|
|
|
2015-07-11 05:44:25 +03:00
|
|
|
// GRAPHICS_SANITY_TEST_REASON enumeration values.
|
2016-11-11 01:48:04 +03:00
|
|
|
const REASON_FIRST_RUN = 0;
|
|
|
|
const REASON_FIREFOX_CHANGED = 1;
|
|
|
|
const REASON_DEVICE_CHANGED = 2;
|
|
|
|
const REASON_DRIVER_CHANGED = 3;
|
2017-07-11 05:30:52 +03:00
|
|
|
const REASON_AL_CONFIG_CHANGED = 4;
|
2020-02-19 02:19:14 +03:00
|
|
|
const REASON_WR_CONFIG_CHANGED = 5;
|
2015-07-11 05:44:25 +03:00
|
|
|
|
2015-06-17 01:49:26 +03:00
|
|
|
function testPixel(ctx, x, y, r, g, b, a, fuzz) {
|
|
|
|
var data = ctx.getImageData(x, y, 1, 1);
|
|
|
|
|
|
|
|
if (
|
|
|
|
Math.abs(data.data[0] - r) <= fuzz &&
|
|
|
|
Math.abs(data.data[1] - g) <= fuzz &&
|
|
|
|
Math.abs(data.data[2] - b) <= fuzz &&
|
|
|
|
Math.abs(data.data[3] - a) <= fuzz
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function reportResult(val) {
|
|
|
|
try {
|
|
|
|
let histogram = Services.telemetry.getHistogramById("GRAPHICS_SANITY_TEST");
|
|
|
|
histogram.add(val);
|
|
|
|
} catch (e) {}
|
|
|
|
|
2017-07-31 20:36:32 +03:00
|
|
|
Services.prefs.setBoolPref(RUNNING_PREF, false);
|
2015-06-17 01:49:26 +03:00
|
|
|
Services.prefs.savePrefFile(null);
|
|
|
|
}
|
|
|
|
|
2015-07-11 05:44:25 +03:00
|
|
|
function reportTestReason(val) {
|
|
|
|
let histogram = Services.telemetry.getHistogramById(
|
|
|
|
"GRAPHICS_SANITY_TEST_REASON"
|
|
|
|
);
|
|
|
|
histogram.add(val);
|
|
|
|
}
|
|
|
|
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
function annotateCrashReport() {
|
2015-07-11 05:44:30 +03:00
|
|
|
try {
|
|
|
|
var crashReporter = Cc["@mozilla.org/toolkit/crash-reporter;1"].getService(
|
|
|
|
Ci.nsICrashReporter
|
|
|
|
);
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
crashReporter.annotateCrashReport("GraphicsSanityTest", "1");
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeCrashReportAnnotation(value) {
|
|
|
|
try {
|
|
|
|
var crashReporter = Cc["@mozilla.org/toolkit/crash-reporter;1"].getService(
|
|
|
|
Ci.nsICrashReporter
|
|
|
|
);
|
|
|
|
crashReporter.removeCrashReportAnnotation("GraphicsSanityTest");
|
2015-07-11 05:44:30 +03:00
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
|
2015-09-04 06:58:48 +03:00
|
|
|
function setTimeout(aMs, aCallback) {
|
|
|
|
var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
|
|
timer.initWithCallback(aCallback, aMs, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
|
2015-06-18 23:42:35 +03:00
|
|
|
function takeWindowSnapshot(win, ctx) {
|
2015-06-17 01:49:26 +03:00
|
|
|
// TODO: drawWindow reads back from the gpu's backbuffer, which won't catch issues with presenting
|
|
|
|
// the front buffer via the window manager. Ideally we'd use an OS level API for reading back
|
|
|
|
// from the desktop itself to get a more accurate test.
|
|
|
|
var flags =
|
|
|
|
ctx.DRAWWINDOW_DRAW_CARET |
|
|
|
|
ctx.DRAWWINDOW_DRAW_VIEW |
|
|
|
|
ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
|
|
|
|
ctx.drawWindow(
|
|
|
|
win.ownerGlobal,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
PAGE_WIDTH,
|
|
|
|
PAGE_HEIGHT,
|
|
|
|
"rgb(255,255,255)",
|
|
|
|
flags
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that all the 4 coloured squares of the video
|
|
|
|
// render as expected (with a tolerance of 64 to allow for
|
|
|
|
// yuv->rgb differences between platforms).
|
|
|
|
//
|
2017-09-07 20:36:20 +03:00
|
|
|
// The video is VIDEO_WIDTH*VIDEO_HEIGHT, and is split into quadrants of
|
|
|
|
// different colours. The top left of the video is LEFT_EDGE,TOP_EDGE+CANVAS_HEIGHT
|
|
|
|
// and we test a pixel into the middle of each quadrant to avoid
|
2015-06-17 01:49:26 +03:00
|
|
|
// blending differences at the edges.
|
|
|
|
//
|
|
|
|
// We allow massive amounts of fuzz for the colours since
|
|
|
|
// it can depend hugely on the yuv -> rgb conversion, and
|
|
|
|
// we don't want to fail unnecessarily.
|
|
|
|
function verifyVideoRendering(ctx) {
|
2017-09-07 20:36:20 +03:00
|
|
|
return (
|
|
|
|
testPixel(
|
|
|
|
ctx,
|
|
|
|
LEFT_EDGE + VIDEO_WIDTH / 4,
|
|
|
|
TOP_EDGE + CANVAS_HEIGHT + VIDEO_HEIGHT / 4,
|
|
|
|
255,
|
|
|
|
255,
|
|
|
|
255,
|
|
|
|
255,
|
|
|
|
64
|
|
|
|
) &&
|
|
|
|
testPixel(
|
|
|
|
ctx,
|
|
|
|
LEFT_EDGE + (3 * VIDEO_WIDTH) / 4,
|
|
|
|
TOP_EDGE + CANVAS_HEIGHT + VIDEO_HEIGHT / 4,
|
|
|
|
0,
|
|
|
|
255,
|
|
|
|
0,
|
|
|
|
255,
|
|
|
|
64
|
|
|
|
) &&
|
|
|
|
testPixel(
|
|
|
|
ctx,
|
|
|
|
LEFT_EDGE + VIDEO_WIDTH / 4,
|
|
|
|
TOP_EDGE + CANVAS_HEIGHT + (3 * VIDEO_HEIGHT) / 4,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
255,
|
|
|
|
255,
|
|
|
|
64
|
|
|
|
) &&
|
|
|
|
testPixel(
|
|
|
|
ctx,
|
|
|
|
LEFT_EDGE + (3 * VIDEO_WIDTH) / 4,
|
|
|
|
TOP_EDGE + CANVAS_HEIGHT + (3 * VIDEO_HEIGHT) / 4,
|
|
|
|
255,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
255,
|
|
|
|
64
|
2019-07-05 12:14:05 +03:00
|
|
|
)
|
2017-09-07 20:36:20 +03:00
|
|
|
);
|
2015-06-17 01:49:26 +03:00
|
|
|
}
|
|
|
|
|
2015-06-29 22:41:59 +03:00
|
|
|
// Verify that the middle of the layers test is the color we expect.
|
2017-09-07 20:19:35 +03:00
|
|
|
// It's a red CANVAS_WIDTHxCANVAS_HEIGHT square, test a pixel deep into the
|
|
|
|
// square to prevent fuzzing, and another outside the expected limit of the
|
|
|
|
// square to check that scaling occurred properly. The square is drawn LEFT_EDGE
|
|
|
|
// pixels from the window's left edge and TOP_EDGE from the window's top edge.
|
2015-06-29 22:41:59 +03:00
|
|
|
function verifyLayersRendering(ctx) {
|
2017-09-07 20:19:35 +03:00
|
|
|
return (
|
|
|
|
testPixel(
|
|
|
|
ctx,
|
|
|
|
LEFT_EDGE + CANVAS_WIDTH / 2,
|
|
|
|
TOP_EDGE + CANVAS_HEIGHT / 2,
|
|
|
|
255,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
255,
|
|
|
|
64
|
2019-07-05 12:14:05 +03:00
|
|
|
) &&
|
2017-09-07 20:19:35 +03:00
|
|
|
testPixel(
|
|
|
|
ctx,
|
|
|
|
LEFT_EDGE + CANVAS_WIDTH,
|
|
|
|
TOP_EDGE + CANVAS_HEIGHT / 2,
|
|
|
|
255,
|
|
|
|
255,
|
2019-07-05 12:14:05 +03:00
|
|
|
255,
|
|
|
|
255,
|
|
|
|
64
|
|
|
|
)
|
2017-09-07 20:19:35 +03:00
|
|
|
);
|
2015-06-29 22:41:59 +03:00
|
|
|
}
|
|
|
|
|
2017-07-11 05:30:52 +03:00
|
|
|
function testCompositor(test, win, ctx) {
|
2021-01-20 10:33:17 +03:00
|
|
|
if (win.windowUtils.layerManagerType.startsWith("WebRender")) {
|
2020-02-19 02:19:14 +03:00
|
|
|
// When layer manger type is WebRender, drawWindow() is skipped, since
|
|
|
|
// drawWindow() could take long time and
|
|
|
|
// advanced layer is disabled from fallback candidate.
|
|
|
|
if (Services.prefs.getBoolPref(AL_ENABLED_PREF, false)) {
|
|
|
|
Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, true);
|
|
|
|
}
|
2020-02-20 12:10:51 +03:00
|
|
|
reportResult(TEST_PASSED);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
takeWindowSnapshot(win, ctx);
|
|
|
|
var testPassed = true;
|
|
|
|
|
|
|
|
if (!verifyLayersRendering(ctx)) {
|
2017-09-07 20:19:35 +03:00
|
|
|
// Try disabling advanced layers if it was enabled. Also trigger
|
2017-07-11 05:30:52 +03:00
|
|
|
// a device reset so the screen redraws.
|
2017-07-31 20:36:32 +03:00
|
|
|
if (Services.prefs.getBoolPref(AL_ENABLED_PREF, false)) {
|
|
|
|
Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, true);
|
2018-10-23 05:42:59 +03:00
|
|
|
// Do not need to reset device when WebRender is used.
|
|
|
|
// When WebRender is used, advanced layers are not used.
|
|
|
|
if (test.utils.layerManagerType != "WebRender") {
|
|
|
|
test.utils.triggerDeviceReset();
|
|
|
|
}
|
2017-07-11 05:30:52 +03:00
|
|
|
}
|
2015-06-29 22:41:59 +03:00
|
|
|
reportResult(TEST_FAILED_RENDER);
|
2015-07-08 23:00:17 +03:00
|
|
|
testPassed = false;
|
2017-07-11 05:30:52 +03:00
|
|
|
} else {
|
2017-07-31 20:36:32 +03:00
|
|
|
Services.prefs.setBoolPref(AL_TEST_FAILED_PREF, false);
|
2017-09-07 20:19:35 +03:00
|
|
|
if (!verifyVideoRendering(ctx)) {
|
|
|
|
reportResult(TEST_FAILED_VIDEO);
|
|
|
|
Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, true);
|
|
|
|
testPassed = false;
|
|
|
|
}
|
2015-06-29 22:41:59 +03:00
|
|
|
}
|
|
|
|
|
2015-07-08 23:00:17 +03:00
|
|
|
if (testPassed) {
|
|
|
|
reportResult(TEST_PASSED);
|
|
|
|
}
|
|
|
|
|
|
|
|
return testPassed;
|
2015-06-17 01:49:26 +03:00
|
|
|
}
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var listener = {
|
2015-06-18 23:42:35 +03:00
|
|
|
win: null,
|
2015-06-18 23:44:04 +03:00
|
|
|
utils: null,
|
2015-06-18 23:42:35 +03:00
|
|
|
canvas: null,
|
2016-04-28 11:47:47 +03:00
|
|
|
ctx: null,
|
2015-07-08 23:00:17 +03:00
|
|
|
mm: null,
|
|
|
|
|
|
|
|
messages: ["gfxSanity:ContentLoaded"],
|
2015-06-18 23:42:35 +03:00
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
scheduleTest(win) {
|
2015-06-18 23:42:35 +03:00
|
|
|
this.win = win;
|
|
|
|
this.win.onload = this.onWindowLoaded.bind(this);
|
2018-07-25 02:47:42 +03:00
|
|
|
this.utils = this.win.windowUtils;
|
2015-09-04 06:58:48 +03:00
|
|
|
setTimeout(TIMEOUT_SEC * 1000, () => {
|
|
|
|
if (this.win) {
|
|
|
|
reportResult(TEST_TIMEOUT);
|
|
|
|
this.endTest();
|
|
|
|
}
|
|
|
|
});
|
2015-06-18 23:42:35 +03:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
runSanityTest() {
|
2015-06-18 23:42:35 +03:00
|
|
|
this.canvas = this.win.document.createElementNS(
|
|
|
|
"http://www.w3.org/1999/xhtml",
|
|
|
|
"canvas"
|
|
|
|
);
|
|
|
|
this.canvas.setAttribute("width", PAGE_WIDTH);
|
|
|
|
this.canvas.setAttribute("height", PAGE_HEIGHT);
|
|
|
|
this.ctx = this.canvas.getContext("2d");
|
|
|
|
|
2015-06-18 23:44:04 +03:00
|
|
|
// Perform the compositor backbuffer test, which currently we use for
|
|
|
|
// actually deciding whether to enable hardware media decoding.
|
2017-07-11 05:30:52 +03:00
|
|
|
testCompositor(this, this.win, this.ctx);
|
2015-07-08 23:00:17 +03:00
|
|
|
|
2015-06-18 23:44:04 +03:00
|
|
|
this.endTest();
|
2015-06-18 23:42:35 +03:00
|
|
|
},
|
2015-06-18 23:44:04 +03:00
|
|
|
|
2015-07-08 23:00:17 +03:00
|
|
|
receiveMessage(message) {
|
|
|
|
switch (message.name) {
|
|
|
|
case "gfxSanity:ContentLoaded":
|
|
|
|
this.runSanityTest();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
onWindowLoaded() {
|
2018-08-14 19:22:44 +03:00
|
|
|
let browser = this.win.document.createXULElement("browser");
|
2015-07-08 23:00:17 +03:00
|
|
|
browser.setAttribute("type", "content");
|
2017-06-16 10:58:06 +03:00
|
|
|
browser.setAttribute("disableglobalhistory", "true");
|
2015-07-08 23:00:17 +03:00
|
|
|
|
|
|
|
let remoteBrowser = Services.appinfo.browserTabsRemoteAutostart;
|
|
|
|
browser.setAttribute("remote", remoteBrowser);
|
|
|
|
|
|
|
|
browser.style.width = PAGE_WIDTH + "px";
|
|
|
|
browser.style.height = PAGE_HEIGHT + "px";
|
|
|
|
|
|
|
|
this.win.document.documentElement.appendChild(browser);
|
|
|
|
// Have to set the mm after we append the child
|
|
|
|
this.mm = browser.messageManager;
|
|
|
|
|
|
|
|
this.messages.forEach(msgName => {
|
|
|
|
this.mm.addMessageListener(msgName, this);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.mm.loadFrameScript(FRAME_SCRIPT_URL, false);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
endTest() {
|
2015-06-18 23:44:04 +03:00
|
|
|
if (!this.win) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.win.ownerGlobal.close();
|
|
|
|
this.win = null;
|
|
|
|
this.utils = null;
|
|
|
|
this.canvas = null;
|
2016-04-28 11:47:47 +03:00
|
|
|
this.ctx = null;
|
2015-06-18 23:44:04 +03:00
|
|
|
|
2015-09-19 04:37:57 +03:00
|
|
|
if (this.mm) {
|
|
|
|
// We don't have a MessageManager if onWindowLoaded never fired.
|
|
|
|
this.messages.forEach(msgName => {
|
|
|
|
this.mm.removeMessageListener(msgName, this);
|
|
|
|
});
|
2015-07-08 23:00:17 +03:00
|
|
|
|
2015-09-19 04:37:57 +03:00
|
|
|
this.mm = null;
|
|
|
|
}
|
2016-02-04 01:22:33 +03:00
|
|
|
|
2015-07-11 05:44:30 +03:00
|
|
|
// Remove the annotation after we've cleaned everything up, to catch any
|
|
|
|
// incidental crashes from having performed the sanity test.
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
removeCrashReportAnnotation();
|
2015-06-18 23:44:04 +03:00
|
|
|
},
|
2015-06-18 23:42:35 +03:00
|
|
|
};
|
|
|
|
|
2015-06-17 01:49:26 +03:00
|
|
|
function SanityTest() {}
|
|
|
|
SanityTest.prototype = {
|
|
|
|
classID: Components.ID("{f3a8ca4d-4c83-456b-aee2-6a2cbf11e9bd}"),
|
|
|
|
QueryInterface: ChromeUtils.generateQI([
|
Bug 1649221: Update ChromeUtils.generateQI callers to pass strings. r=mccr8,remote-protocol-reviewers,marionette-reviewers,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,preferences-reviewers,agi,whimboo,Bebe,twisniewski
Differential Revision: https://phabricator.services.mozilla.com/D81594
2020-07-11 02:58:28 +03:00
|
|
|
"nsIObserver",
|
|
|
|
"nsISupportsWeakReference",
|
2015-06-17 01:49:26 +03:00
|
|
|
]),
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
shouldRunTest() {
|
2015-06-17 01:49:26 +03:00
|
|
|
// Only test gfx features if firefox has updated, or if the user has a new
|
|
|
|
// gpu or drivers.
|
2016-03-10 05:01:58 +03:00
|
|
|
var buildId = Services.appinfo.platformBuildID;
|
2015-06-17 01:49:26 +03:00
|
|
|
var gfxinfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
|
2017-07-31 20:36:32 +03:00
|
|
|
var hasAL = Services.prefs.getBoolPref(AL_ENABLED_PREF, false);
|
2020-02-19 02:19:14 +03:00
|
|
|
var disableWR = Services.prefs.getBoolPref(WR_DISABLED_PREF, false);
|
2015-06-17 01:49:26 +03:00
|
|
|
|
2017-07-31 20:36:32 +03:00
|
|
|
if (Services.prefs.getBoolPref(RUNNING_PREF, false)) {
|
|
|
|
Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, true);
|
2015-06-17 01:49:26 +03:00
|
|
|
reportResult(TEST_CRASHED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-11 05:44:25 +03:00
|
|
|
function checkPref(pref, value, reason) {
|
2017-07-31 20:36:32 +03:00
|
|
|
let prefValue;
|
|
|
|
let prefType = Services.prefs.getPrefType(pref);
|
|
|
|
|
|
|
|
switch (prefType) {
|
|
|
|
case Ci.nsIPrefBranch.PREF_INVALID:
|
|
|
|
reportTestReason(REASON_FIRST_RUN);
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case Ci.nsIPrefBranch.PREF_STRING:
|
|
|
|
prefValue = Services.prefs.getStringPref(pref);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIPrefBranch.PREF_BOOL:
|
|
|
|
prefValue = Services.prefs.getBoolPref(pref);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Ci.nsIPrefBranch.PREF_INT:
|
|
|
|
prefValue = Services.prefs.getIntPref(pref);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new Error("Unexpected preference type.");
|
2015-07-11 05:44:25 +03:00
|
|
|
}
|
2017-07-31 20:36:32 +03:00
|
|
|
|
|
|
|
if (prefValue != value) {
|
2015-07-11 05:44:25 +03:00
|
|
|
reportTestReason(reason);
|
2017-07-31 20:36:32 +03:00
|
|
|
return false;
|
2015-07-11 05:44:25 +03:00
|
|
|
}
|
2017-07-31 20:36:32 +03:00
|
|
|
|
|
|
|
return true;
|
2015-07-11 05:44:25 +03:00
|
|
|
}
|
|
|
|
|
2015-06-17 01:49:26 +03:00
|
|
|
// TODO: Handle dual GPU setups
|
2015-07-11 05:44:25 +03:00
|
|
|
if (
|
|
|
|
checkPref(
|
|
|
|
DRIVER_PREF,
|
|
|
|
gfxinfo.adapterDriverVersion,
|
|
|
|
REASON_DRIVER_CHANGED
|
|
|
|
) &&
|
|
|
|
checkPref(DEVICE_PREF, gfxinfo.adapterDeviceID, REASON_DEVICE_CHANGED) &&
|
2017-07-11 05:30:52 +03:00
|
|
|
checkPref(VERSION_PREF, buildId, REASON_FIREFOX_CHANGED) &&
|
2020-02-19 02:19:14 +03:00
|
|
|
checkPref(ADVANCED_LAYERS_PREF, hasAL, REASON_AL_CONFIG_CHANGED) &&
|
|
|
|
checkPref(WEBRENDER_DISABLED_PREF, disableWR, REASON_WR_CONFIG_CHANGED)
|
2017-07-11 05:30:52 +03:00
|
|
|
) {
|
2015-06-17 01:49:26 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enable hardware decoding so we can test again
|
|
|
|
// and record the driver version to detect if the driver changes.
|
2017-07-31 20:36:32 +03:00
|
|
|
Services.prefs.setBoolPref(DISABLE_VIDEO_PREF, false);
|
|
|
|
Services.prefs.setStringPref(DRIVER_PREF, gfxinfo.adapterDriverVersion);
|
|
|
|
Services.prefs.setStringPref(DEVICE_PREF, gfxinfo.adapterDeviceID);
|
|
|
|
Services.prefs.setStringPref(VERSION_PREF, buildId);
|
|
|
|
Services.prefs.setBoolPref(ADVANCED_LAYERS_PREF, hasAL);
|
2020-02-19 02:19:14 +03:00
|
|
|
Services.prefs.setBoolPref(WEBRENDER_DISABLED_PREF, disableWR);
|
2015-06-17 01:49:26 +03:00
|
|
|
|
|
|
|
// Update the prefs so that this test doesn't run again until the next update.
|
2017-07-31 20:36:32 +03:00
|
|
|
Services.prefs.setBoolPref(RUNNING_PREF, true);
|
2015-06-17 01:49:26 +03:00
|
|
|
Services.prefs.savePrefFile(null);
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
observe(subject, topic, data) {
|
2015-06-17 01:49:26 +03:00
|
|
|
if (topic != "profile-after-change") {
|
|
|
|
return;
|
2019-07-05 12:14:05 +03:00
|
|
|
}
|
2020-10-28 04:12:57 +03:00
|
|
|
if (Services.prefs.getBoolPref(TEST_DISABLED_PREF, false)) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-28 11:47:47 +03:00
|
|
|
|
|
|
|
// profile-after-change fires only at startup, so we won't need
|
|
|
|
// to use the listener again.
|
|
|
|
let tester = listener;
|
|
|
|
listener = null;
|
|
|
|
|
2015-06-17 01:49:26 +03:00
|
|
|
if (!this.shouldRunTest()) {
|
|
|
|
return;
|
2019-07-05 12:14:05 +03:00
|
|
|
}
|
2015-06-17 01:49:26 +03:00
|
|
|
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
annotateCrashReport();
|
2015-07-11 05:44:30 +03:00
|
|
|
|
2015-06-17 01:49:26 +03:00
|
|
|
// Open a tiny window to render our test page, and notify us when it's loaded
|
|
|
|
var sanityTest = Services.ww.openWindow(
|
|
|
|
null,
|
2015-07-08 23:00:17 +03:00
|
|
|
"chrome://gfxsanity/content/sanityparent.html",
|
2015-06-17 01:49:26 +03:00
|
|
|
"Test Page",
|
2018-07-09 20:18:10 +03:00
|
|
|
"width=" +
|
|
|
|
PAGE_WIDTH +
|
|
|
|
",height=" +
|
|
|
|
PAGE_HEIGHT +
|
|
|
|
",chrome,titlebar=0,scrollbars=0,popup=1",
|
2015-06-17 01:49:26 +03:00
|
|
|
null
|
|
|
|
);
|
2015-07-02 22:47:10 +03:00
|
|
|
|
|
|
|
// There's no clean way to have an invisible window and ensure it's always painted.
|
|
|
|
// Instead, move the window far offscreen so it doesn't show up during launch.
|
2016-08-16 22:44:15 +03:00
|
|
|
sanityTest.moveTo(100000000, 1000000000);
|
2017-09-07 18:49:05 +03:00
|
|
|
// In multi-screens with different dpi setup, the window may have been
|
|
|
|
// incorrectly resized.
|
|
|
|
sanityTest.resizeTo(PAGE_WIDTH, PAGE_HEIGHT);
|
2016-04-28 11:47:47 +03:00
|
|
|
tester.scheduleTest(sanityTest);
|
2015-06-17 01:49:26 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-01-30 21:37:01 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["SanityTest"];
|