Bug 1795139 - Show fullscreen notification as soon as browser window goes into fullscreen mode; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D159383
This commit is contained in:
Edgar Chen 2022-10-19 23:02:52 +00:00
Родитель ff93da3728
Коммит b9ef11123d
3 изменённых файлов: 25 добавлений и 21 удалений

Просмотреть файл

@ -197,6 +197,12 @@ export class DOMFullscreenParent extends JSWindowActorParent {
TelemetryStopwatch.start("FULLSCREEN_CHANGE_MS");
window.FullScreen.enterDomFullscreen(browser, this);
this.updateFullscreenWindowReference(window);
if (!this.hasBeenDestroyed() && this.requestOrigin) {
window.PointerlockFsWarning.showFullScreen(
this.requestOrigin.manager.documentPrincipal.originNoSuffix
);
}
break;
}
case "MozDOMFullscreen:Exited": {

Просмотреть файл

@ -15069,12 +15069,12 @@ bool Document::ApplyFullscreen(UniquePtr<FullscreenRequest> aRequest) {
// The origin which is fullscreen gets changed. Trigger an event so
// that the chrome knows to pop up a warning UI. Note that
// previousFullscreenDoc == nullptr upon first entry, so we always
// take this path on the first entry. Also note that, in a multi-
// process browser, the code in content process is responsible for
// sending message with the origin to its parent, and the parent
// shouldn't rely on this event itself.
if (aRequest->mShouldNotifyNewOrigin &&
// previousFullscreenDoc == nullptr upon first entry, we show the warning UI
// directly as soon as chrome document goes into fullscreen state. Also note
// that, in a multi-process browser, the code in content process is
// responsible for sending message with the origin to its parent, and the
// parent shouldn't rely on this event itself.
if (aRequest->mShouldNotifyNewOrigin && previousFullscreenDoc &&
!nsContentUtils::HaveEqualPrincipals(previousFullscreenDoc, this)) {
DispatchFullscreenNewOriginEvent(this);
}

Просмотреть файл

@ -38,28 +38,26 @@ var gOuterDoc = null;
var gInnerDoc = null;
var gReceivedFullscreenEnteredEvent = false;
var gReceivedNewOriginEvent = false;
function firstEntry(event) {
if (event.type == "MozDOMFullscreen:Entered") {
window.removeEventListener("MozDOMFullscreen:Entered", firstEntry, false);
ok(!gReceivedFullscreenEnteredEvent, "MozDOMFullscreen:Entered shouldn't have been triggered twice");
is(event.target, gOuterDoc.body, "First MozDOMFullscreen:Entered should be targeted at outer body");
gReceivedFullscreenEnteredEvent = true;
} else if (event.type == "MozDOMFullscreen:NewOrigin") {
window.removeEventListener("MozDOMFullscreen:NewOrigin", firstEntry, false);
ok(!gReceivedNewOriginEvent, "MozDOMFullscreen:NewOrigin shouldn't have been triggered twice");
is(event.target, gOuterDoc, "First MozDOMFullscreen:NewOrigin should be targeted at outer doc");
gReceivedNewOriginEvent = true;
} else {
ok(false, "Unknown event received");
if (event.type == "MozDOMFullscreen:NewOrigin") {
ok(false, "MozDOMFullscreen:NewOrigin shouldn't be triggered at first entry");
return;
}
if (!gReceivedFullscreenEnteredEvent || !gReceivedNewOriginEvent) {
if (event.type != "MozDOMFullscreen:Entered") {
ok(false, "Unknown event received");
return;
}
ok(gOuterDoc.fullscreenElement != null, "Outer doc should be in fullscreen");
is(event.target, gOuterDoc.body, "First MozDOMFullscreen:Entered should be targeted at outer body");
ok(!gReceivedFullscreenEnteredEvent, "MozDOMFullscreen:Entered shouldn't have been triggered twice");
gReceivedFullscreenEnteredEvent = true;
window.removeEventListener("MozDOMFullscreen:Entered", firstEntry);
window.removeEventListener("MozDOMFullscreen:NewOrigin", firstEntry);
window.addEventListener("MozDOMFullscreen:NewOrigin", secondEntry);
gInnerDoc = gOuterDoc.getElementById("innerFrame").contentDocument;
window.addEventListener("MozDOMFullscreen:NewOrigin", secondEntry, false);
gInnerDoc.defaultView.focus();
gInnerDoc.body.requestFullscreen();
}