Bug 1129227 - Part 2: Switch Fullscreen to use transient-user-activation API; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D47151
This commit is contained in:
@@ -3283,22 +3283,16 @@ CORSMode Element::AttrValueToCORSMode(const nsAttrValue* aValue) {
|
||||
* setting the pref "full-screen-api.allow-trusted-requests-only" to false.
|
||||
* If fullscreen is not allowed, a key for the error message is returned.
|
||||
*/
|
||||
static const char* GetFullscreenError(CallerType aCallerType) {
|
||||
static const char* GetFullscreenError(CallerType aCallerType,
|
||||
Document* aDocument) {
|
||||
MOZ_ASSERT(aDocument);
|
||||
|
||||
if (!StaticPrefs::full_screen_api_allow_trusted_requests_only() ||
|
||||
aCallerType == CallerType::System) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!UserActivation::IsHandlingUserInput()) {
|
||||
return "FullscreenDeniedNotInputDriven";
|
||||
}
|
||||
|
||||
// If more time has elapsed since the user input than is specified by the
|
||||
// dom.event.handling-user-input-time-limit pref (default 1 second),
|
||||
// disallow fullscreen
|
||||
TimeDuration timeout = nsContentUtils::HandlingUserInputTimeout();
|
||||
if (timeout > TimeDuration(nullptr) &&
|
||||
(TimeStamp::Now() - UserActivation::GetHandlingInputStart()) > timeout) {
|
||||
if (!aDocument->HasValidTransientUserGestureActivation()) {
|
||||
return "FullscreenDeniedNotInputDriven";
|
||||
}
|
||||
|
||||
@@ -3331,7 +3325,7 @@ already_AddRefed<Promise> Element::RequestFullscreen(CallerType aCallerType,
|
||||
// spoof the browser chrome/window and phish logins etc.
|
||||
// Note that requests for fullscreen inside a web app's origin are exempt
|
||||
// from this restriction.
|
||||
if (const char* error = GetFullscreenError(aCallerType)) {
|
||||
if (const char* error = GetFullscreenError(aCallerType, OwnerDoc())) {
|
||||
request->Reject(error);
|
||||
} else {
|
||||
OwnerDoc()->AsyncRequestFullscreen(std::move(request));
|
||||
|
||||
@@ -553,12 +553,6 @@ class nsContentUtils::UserInteractionObserver final
|
||||
~UserInteractionObserver() {}
|
||||
};
|
||||
|
||||
/* static */
|
||||
TimeDuration nsContentUtils::HandlingUserInputTimeout() {
|
||||
return TimeDuration::FromMilliseconds(
|
||||
StaticPrefs::dom_event_handling_user_input_time_limit());
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult nsContentUtils::Init() {
|
||||
if (sInitialized) {
|
||||
|
||||
@@ -2363,13 +2363,6 @@ class nsContentUtils {
|
||||
*/
|
||||
static bool IsInPointerLockContext(nsPIDOMWindowOuter* aWin);
|
||||
|
||||
/**
|
||||
* Returns the time limit on handling user input before
|
||||
* EventStateManager::IsHandlingUserInput() stops returning true.
|
||||
* This enables us to detect long running user-generated event handlers.
|
||||
*/
|
||||
static TimeDuration HandlingUserInputTimeout();
|
||||
|
||||
static void GetShiftText(nsAString& text);
|
||||
static void GetControlText(nsAString& text);
|
||||
static void GetMetaText(nsAString& text);
|
||||
|
||||
@@ -98,12 +98,13 @@ function testNonTrustContext() {
|
||||
}
|
||||
|
||||
function testLongRunningEventHandler() {
|
||||
let timeout = SpecialPowers.getIntPref("dom.user_activation.transient.timeout") + 1000;
|
||||
|
||||
function longRunningHandler() {
|
||||
window.removeEventListener("keypress", longRunningHandler);
|
||||
// Busy loop until 2s has passed. We should then be past the one
|
||||
// second threshold, and so our request for fullscreen should be
|
||||
// rejected.
|
||||
var end = (new Date()).getTime() + 2000;
|
||||
// Busy loop until transient useractivation is timed out, so our request for
|
||||
// fullscreen should be rejected.
|
||||
var end = (new Date()).getTime() + timeout;
|
||||
while ((new Date()).getTime() < end) {
|
||||
; // Wait...
|
||||
}
|
||||
|
||||
@@ -1424,13 +1424,6 @@
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# Time limit, in milliseconds, for EventStateManager::IsHandlingUserInput().
|
||||
# Used to detect long running handlers of user-generated events.
|
||||
- name: dom.event.handling-user-input-time-limit
|
||||
type: uint32_t
|
||||
value: 1000
|
||||
mirror: always
|
||||
|
||||
# Enable clipboard readText() and writeText() by default
|
||||
- name: dom.events.asyncClipboard
|
||||
type: bool
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[fullscreen-report-only.html]
|
||||
expected: TIMEOUT
|
||||
[Fullscreen report only mode]
|
||||
expected: FAIL
|
||||
expected: TIMEOUT
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
[element-request-fullscreen.html]
|
||||
expected: ERROR
|
||||
[Element#requestFullscreen()]
|
||||
expected: FAIL
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
[active-lock.html]
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
[Fragment navigation test: orientation should not change]
|
||||
expected: FAIL
|
||||
|
||||
[When performing a fragment navigation, the orientation must not change or unlock]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
FAIL
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
[event-before-promise.html]
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
[The 'change' event must fire before the [[orientationPendingPromise\]\] is resolved.]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
FAIL
|
||||
|
||||
|
||||
@@ -7,5 +7,7 @@
|
||||
expected: FAIL
|
||||
|
||||
[Test that screen.orientation.lock() is actually async]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
FAIL
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
[lock-unlock-check.html]
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
[lock-unlock-check]
|
||||
expected: FAIL
|
||||
|
||||
[Re-locking orientation during event dispatch must reject existing orientationPendingPromise]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
FAIL
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
[onchange-event.html]
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
[Test that orientationchange event is fired when the orientation changes.]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
FAIL
|
||||
|
||||
[Test that orientationchange event is not fired when the orientation does not change.]
|
||||
expected: FAIL
|
||||
|
||||
expected:
|
||||
if os == "android": PASS
|
||||
FAIL
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
[orientation-reading.html]
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
[Test that screen.orientation values change if the orientation changes]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": NOTRUN
|
||||
FAIL
|
||||
|
||||
[Test the orientations and associated angles]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if os == "android": TIMEOUT
|
||||
FAIL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user