diff --git a/dom/base/ScreenOrientation.cpp b/dom/base/ScreenOrientation.cpp index 5179bb46852c..767590bf6a8b 100644 --- a/dom/base/ScreenOrientation.cpp +++ b/dom/base/ScreenOrientation.cpp @@ -702,6 +702,12 @@ ScreenOrientation::FullscreenEventListener::HandleEvent(Event* aEvent) { return NS_OK; } + BrowsingContext* bc = doc->GetBrowsingContext(); + bc = bc ? bc->Top() : nullptr; + if (bc) { + bc->SetOrientationLock(hal::ScreenOrientation::None, IgnoreErrors()); + } + hal::UnlockScreenOrientation(); target->RemoveSystemEventListener(u"fullscreenchange"_ns, this, true); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index bfae4119fa1d..d97c6b2d5b98 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -4760,3 +4760,22 @@ nsDOMWindowUtils::GetHasScrollLinkedEffect(bool* aResult) { *aResult = doc->HasScrollLinkedEffect(); return NS_OK; } + +NS_IMETHODIMP +nsDOMWindowUtils::GetOrientationLock(uint32_t* aOrientationLock) { + NS_WARNING("nsDOMWindowUtils::GetOrientationLock"); + + nsIDocShell* docShell = GetDocShell(); + if (!docShell) { + return NS_ERROR_FAILURE; + } + + BrowsingContext* bc = docShell->GetBrowsingContext(); + bc = bc ? bc->Top() : nullptr; + if (!bc) { + return NS_ERROR_FAILURE; + } + + *aOrientationLock = static_cast(bc->GetOrientationLock()); + return NS_OK; +} diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index a145621b37af..f0145047ebd3 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -704,6 +704,8 @@ skip-if = !e10s # Track Bug 1281415 [test_link_stylesheet.html] [test_location_href_unknown_protocol.html] support-files = file_location_href_unknown_protocol.html +[test_lock_orientation_after_fullscreen.html] +skip-if = toolkit != 'android' # Only run on Android. [test_meta_refresh_referrer.html] [test_mozMatchesSelector.html] [test_mutationobserver_anonymous.html] diff --git a/dom/base/test/test_lock_orientation_after_fullscreen.html b/dom/base/test/test_lock_orientation_after_fullscreen.html new file mode 100644 index 000000000000..bb448f2b8d7b --- /dev/null +++ b/dom/base/test/test_lock_orientation_after_fullscreen.html @@ -0,0 +1,58 @@ + + + + +Test for Bug 1757431 + + + + +Mozilla Bug 1757431 +
fullscreen
+ + + diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 5602a9b09fc9..4059b2e81fb4 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -2270,6 +2270,10 @@ interface nsIDOMWindowUtils : nsISupports { // See https://firefox-source-docs.mozilla.org/performance/scroll-linked_effects.html // about scroll-linked effects. readonly attribute bool hasScrollLinkedEffect; + + // Returns the current orientation lock value in browsing context. + // This value is defined in hal/HalScreenConfiguration.h + readonly attribute uint32_t orientationLock; }; [scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)]