@ -22,27 +22,6 @@ const DISABLE_VIDEO_PREF="media.hardware-video-decoding.failed";
const RUNNING _PREF = "sanity-test.running" ;
const TIMEOUT _SEC = 20 ;
// GRAPHICS_SANITY_TEST histogram enumeration values
const TEST _PASSED = 0 ;
const TEST _FAILED _RENDER = 1 ;
const TEST _FAILED _VIDEO = 2 ;
const TEST _CRASHED = 3 ;
const TEST _TIMEOUT = 4 ;
// GRAPHICS_SANITY_TEST_REASON enumeration values.
const REASON _FIRST _RUN = 0 ;
const REASON _FIREFOX _CHANGED = 1 ;
const REASON _DEVICE _CHANGED = 2 ;
const REASON _DRIVER _CHANGED = 3 ;
// GRAPHICS_SANITY_TEST_OS_SNAPSHOT histogram enumeration values
const SNAPSHOT _VIDEO _OK = 0 ;
const SNAPSHOT _VIDEO _FAIL = 1 ;
const SNAPSHOT _ERROR = 2 ;
const SNAPSHOT _TIMEOUT = 3 ;
const SNAPSHOT _LAYERS _OK = 4 ;
const SNAPSHOT _LAYERS _FAIL = 5 ;
function testPixel ( ctx , x , y , r , g , b , a , fuzz ) {
var data = ctx . getImageData ( x , y , 1 , 1 ) ;
@ -55,6 +34,11 @@ function testPixel(ctx, x, y, r, g, b, a, fuzz) {
return false ;
}
function stopRunning ( ) {
Preferences . set ( RUNNING _PREF , false ) ;
Services . prefs . savePrefFile ( null ) ;
}
function setTimeout ( aMs , aCallback ) {
var timer = Cc [ '@mozilla.org/timer;1' ] .
createInstance ( Ci . nsITimer ) ;
@ -100,15 +84,18 @@ function testCompositor(win, ctx) {
var testPassed = true ;
if ( ! verifyVideoRendering ( ctx ) ) {
stopRunning ( ) ;
Preferences . set ( DISABLE _VIDEO _PREF , true ) ;
testPassed = false ;
}
if ( ! verifyLayersRendering ( ctx ) ) {
stopRunning ( ) ;
testPassed = false ;
}
if ( testPassed ) {
stopRunning ( ) ;
}
return testPassed ;
@ -130,8 +117,10 @@ var listener = {
this . win . onload = this . onWindowLoaded . bind ( this ) ;
this . utils = this . win . QueryInterface ( Ci . nsIInterfaceRequestor )
. getInterface ( Ci . nsIDOMWindowUtils ) ;
// Stop running the test if it timed out.
setTimeout ( TIMEOUT _SEC * 1000 , ( ) => {
if ( this . win ) {
stopRunning ( ) ;
this . endTest ( ) ;
}
} ) ;
@ -208,17 +197,19 @@ SanityTest.prototype = {
Ci . nsISupportsWeakReference ] ) ,
shouldRunTest : function ( ) {
// Only test gfx features if firefox has updated, or if the user has a new
// gpu or drivers.
// Only test GFX features if the application was updated, or if the user
// has a new GPU or drivers.
var buildId = Services . appinfo . platformBuildID ;
var gfxinfo = Cc [ "@mozilla.org/gfx/info;1" ] . getService ( Ci . nsIGfxInfo ) ;
// Stop the test and disable hardware video decoding if we crashed.
if ( Preferences . get ( RUNNING _PREF , false ) ) {
Preferences . set ( DISABLE _VIDEO _PREF , true ) ;
stopRunning ( ) ;
return false ;
}
function checkPref ( pref , value , reason ) {
function checkPref ( pref , value ) {
var prefValue = Preferences . get ( pref , undefined ) ;
if ( prefValue == value ) {
return true ;
@ -227,9 +218,9 @@ SanityTest.prototype = {
}
// TODO: Handle dual GPU setups
if ( checkPref ( DRIVER _PREF , gfxinfo . adapterDriverVersion , REASON _DRIVER _CHANGED ) &&
checkPref ( DEVICE _PREF , gfxinfo . adapterDeviceID , REASON _DEVICE _CHANGED ) &&
checkPref ( VERSION _PREF , buildId , REASON _FIREFOX _CHANGED ) )
if ( checkPref ( DRIVER _PREF , gfxinfo . adapterDriverVersion ) &&
checkPref ( DEVICE _PREF , gfxinfo . adapterDeviceID ) &&
checkPref ( VERSION _PREF , buildId ) )
{
return false ;
}