diff options
Diffstat (limited to 'toolkit/components/gfx/content')
-rw-r--r-- | toolkit/components/gfx/content/gfxFrameScript.js | 73 | ||||
-rw-r--r-- | toolkit/components/gfx/content/sanityparent.html | 8 | ||||
-rw-r--r-- | toolkit/components/gfx/content/sanitytest.html | 10 | ||||
-rw-r--r-- | toolkit/components/gfx/content/videotest.mp4 | bin | 0 -> 1721 bytes |
4 files changed, 91 insertions, 0 deletions
diff --git a/toolkit/components/gfx/content/gfxFrameScript.js b/toolkit/components/gfx/content/gfxFrameScript.js new file mode 100644 index 0000000000..c423fb8a2d --- /dev/null +++ b/toolkit/components/gfx/content/gfxFrameScript.js @@ -0,0 +1,73 @@ +/* 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/. */ + +/* eslint-env mozilla/frame-script */ + +const gfxFrameScript = { + domUtils: null, + + init() { + let webNav = docShell.QueryInterface(Ci.nsIWebNavigation); + let webProgress = docShell + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebProgress); + webProgress.addProgressListener( + this, + Ci.nsIWebProgress.NOTIFY_STATE_WINDOW + ); + + this.domUtils = content.windowUtils; + + let loadURIOptions = { + triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), + }; + webNav.loadURI( + Services.io.newURI("chrome://gfxsanity/content/sanitytest.html"), + loadURIOptions + ); + }, + + handleEvent(aEvent) { + switch (aEvent.type) { + case "MozAfterPaint": + sendAsyncMessage("gfxSanity:ContentLoaded"); + removeEventListener("MozAfterPaint", this); + break; + } + }, + + isSanityTest(aUri) { + if (!aUri) { + return false; + } + + return aUri.endsWith("/sanitytest.html"); + }, + + onStateChange(webProgress, req, flags, status) { + if ( + webProgress.isTopLevel && + flags & Ci.nsIWebProgressListener.STATE_STOP && + this.isSanityTest(req.name) + ) { + webProgress.removeProgressListener(this); + + // If no paint is pending, then the test already painted + if (this.domUtils.isMozAfterPaintPending) { + addEventListener("MozAfterPaint", this); + } else { + sendAsyncMessage("gfxSanity:ContentLoaded"); + } + } + }, + + // Needed to support web progress listener + QueryInterface: ChromeUtils.generateQI([ + "nsIWebProgressListener", + "nsISupportsWeakReference", + "nsIObserver", + ]), +}; + +gfxFrameScript.init(); diff --git a/toolkit/components/gfx/content/sanityparent.html b/toolkit/components/gfx/content/sanityparent.html new file mode 100644 index 0000000000..3f1dc4a894 --- /dev/null +++ b/toolkit/components/gfx/content/sanityparent.html @@ -0,0 +1,8 @@ +<!-- 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/. --> + +<html> + <head> </head> + <body></body> +</html> diff --git a/toolkit/components/gfx/content/sanitytest.html b/toolkit/components/gfx/content/sanitytest.html new file mode 100644 index 0000000000..a99fbc98cf --- /dev/null +++ b/toolkit/components/gfx/content/sanitytest.html @@ -0,0 +1,10 @@ +<!-- 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/. --> + +<html> + <body> + <div style="width: 32px; height: 64px; background-color: red"></div> + <video src="videotest.mp4"></video> + </body> +</html> diff --git a/toolkit/components/gfx/content/videotest.mp4 b/toolkit/components/gfx/content/videotest.mp4 Binary files differnew file mode 100644 index 0000000000..425c1cd5c5 --- /dev/null +++ b/toolkit/components/gfx/content/videotest.mp4 |