author | David Anderson <danderson@mozilla.com> |
Thu, 18 Jun 2015 13:42:35 -0700 | |
changeset 249670 | 4aefa21c8eadfd1594267e0aacd9a2b6b3964d85 |
parent 249669 | de1ddaec57b7434b11528068e9a59c8c5716dd0f |
child 249671 | 451e24d7ed64df2afbd669a7a9732f520f7e9a3f |
push id | 28936 |
push user | ryanvm@gmail.com |
push date | Fri, 19 Jun 2015 20:34:42 +0000 |
treeherder | mozilla-central@c319f262ce3e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mattwoodrow |
bugs | 1173117 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/components/gfx/SanityTest.js +++ b/toolkit/components/gfx/SanityTest.js @@ -41,31 +41,24 @@ function reportResult(val) { let histogram = Services.telemetry.getHistogramById("GRAPHICS_SANITY_TEST"); histogram.add(val); } catch (e) {} Preferences.set(RUNNING_PREF, false); Services.prefs.savePrefFile(null); } -function takeWindowSnapshot(win) { +function takeWindowSnapshot(win, ctx) { // Take a snapshot of the window contents, and then close the window - var canvas = win.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); - canvas.setAttribute("width", PAGE_WIDTH); - canvas.setAttribute("height", PAGE_HEIGHT); - + // // 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 ctx = canvas.getContext("2d"); 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); - - win.ownerGlobal.close(); - return ctx; } // 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). // // The video is 64x64, and is split into quadrants of // different colours. The top left of the video is 8,72 @@ -77,28 +70,52 @@ function takeWindowSnapshot(win) { // we don't want to fail unnecessarily. function verifyVideoRendering(ctx) { return testPixel(ctx, 18, 82, 255, 255, 255, 255, 64) && testPixel(ctx, 50, 82, 0, 255, 0, 255, 64) && testPixel(ctx, 18, 114, 0, 0, 255, 255, 64) && testPixel(ctx, 50, 114, 255, 0, 0, 255, 64); } -function testGfxFeatures(event) { - var win = event.target; - var canvas = takeWindowSnapshot(win); +function testCompositor(win, ctx) { + takeWindowSnapshot(win, ctx); - if (!verifyVideoRendering(canvas)) { + if (!verifyVideoRendering(ctx)) { reportResult(TEST_FAILED_VIDEO); Preferences.set(DISABLE_VIDEO_PREF, true); - } else { - reportResult(TEST_PASSED); + return false; } + + reportResult(TEST_PASSED); + return true; } +let listener = { + QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), + + win: null, + canvas: null, + + scheduleTest: function(win) { + this.win = win; + this.win.onload = this.onWindowLoaded.bind(this); + }, + + onWindowLoaded: function() { + 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"); + + testCompositor(this.win, this.ctx); + + this.win.ownerGlobal.close(); + }, +}; + function SanityTest() {} SanityTest.prototype = { classID: Components.ID("{f3a8ca4d-4c83-456b-aee2-6a2cbf11e9bd}"), QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]), shouldRunTest: function() { // Only test gfx features if firefox has updated, or if the user has a new @@ -138,13 +155,13 @@ SanityTest.prototype = { if (!this.shouldRunTest()) return; // Open a tiny window to render our test page, and notify us when it's loaded var sanityTest = Services.ww.openWindow(null, "chrome://gfxsanity/content/sanitytest.html", "Test Page", "width=" + PAGE_WIDTH + ",height=" + PAGE_HEIGHT + ",chrome,titlebar=0,scrollbars=0", null); - sanityTest.onload = testGfxFeatures; + listener.scheduleTest(sanityTest); }, }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SanityTest]);