From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- toolkit/components/gfx/content/gfxFrameScript.js | 73 +++++++++++++++++++++++ toolkit/components/gfx/content/sanityparent.html | 8 +++ toolkit/components/gfx/content/sanitytest.html | 10 ++++ toolkit/components/gfx/content/videotest.mp4 | Bin 0 -> 1721 bytes 4 files changed, 91 insertions(+) create mode 100644 toolkit/components/gfx/content/gfxFrameScript.js create mode 100644 toolkit/components/gfx/content/sanityparent.html create mode 100644 toolkit/components/gfx/content/sanitytest.html create mode 100644 toolkit/components/gfx/content/videotest.mp4 (limited to 'toolkit/components/gfx/content') 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 @@ + + + + + + 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 @@ + + + + +
+ + + diff --git a/toolkit/components/gfx/content/videotest.mp4 b/toolkit/components/gfx/content/videotest.mp4 new file mode 100644 index 0000000000..425c1cd5c5 Binary files /dev/null and b/toolkit/components/gfx/content/videotest.mp4 differ -- cgit v1.2.3