Backed out 3 changesets (bug 1129227) for wpt failures at active-lock.html. CLOSED TREE

Backed out changeset 44219f4bafb0 (bug 1129227)
Backed out changeset 69f7db4e75bf (bug 1129227)
Backed out changeset 3edc8921609b (bug 1129227)
This commit is contained in:
Brindusan Cristian 2019-09-27 03:53:36 +03:00
parent a28dd50b63
commit 1991bac5a6
10 changed files with 75 additions and 89 deletions

View File

@ -3319,35 +3319,8 @@ CORSMode Element::AttrValueToCORSMode(const nsAttrValue* aValue) {
return CORSMode(aValue->GetEnumValue());
}
/**
* Returns nullptr if requests for fullscreen are allowed in the current
* context. Requests are only allowed if the user initiated them (like with
* a mouse-click or key press), unless this check has been disabled by
* 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,
Document* aDocument) {
MOZ_ASSERT(aDocument);
if (!StaticPrefs::full_screen_api_allow_trusted_requests_only() ||
aCallerType == CallerType::System) {
return nullptr;
}
if (!aDocument->HasValidTransientUserGestureActivation()) {
return "FullscreenDeniedNotInputDriven";
}
// Entering full-screen on mouse mouse event is only allowed with left mouse
// button
if (StaticPrefs::full_screen_api_mouse_event_allow_left_button_only() &&
(EventStateManager::sCurrentMouseBtn == MouseButton::eMiddle ||
EventStateManager::sCurrentMouseBtn == MouseButton::eRight)) {
return "FullscreenDeniedMouseEventOnlyLeftBtn";
}
return nullptr;
static const char* GetFullscreenError(CallerType aCallerType) {
return nsContentUtils::CheckRequestFullscreenAllowed(aCallerType);
}
already_AddRefed<Promise> Element::RequestFullscreen(CallerType aCallerType,
@ -3368,7 +3341,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, OwnerDoc())) {
if (const char* error = GetFullscreenError(aCallerType)) {
request->Reject(error);
} else {
OwnerDoc()->AsyncRequestFullscreen(std::move(request));

View File

@ -552,6 +552,12 @@ 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) {
@ -6399,6 +6405,38 @@ bool nsContentUtils::ChannelShouldInheritPrincipal(
return inherit;
}
/* static */
const char* nsContentUtils::CheckRequestFullscreenAllowed(
CallerType aCallerType) {
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 = HandlingUserInputTimeout();
if (timeout > TimeDuration(nullptr) &&
(TimeStamp::Now() - UserActivation::GetHandlingInputStart()) > timeout) {
return "FullscreenDeniedNotInputDriven";
}
// Entering full-screen on mouse mouse event is only allowed with left mouse
// button
if (StaticPrefs::full_screen_api_mouse_event_allow_left_button_only() &&
(EventStateManager::sCurrentMouseBtn == MouseButton::eMiddle ||
EventStateManager::sCurrentMouseBtn == MouseButton::eRight)) {
return "FullscreenDeniedMouseEventOnlyLeftBtn";
}
return nullptr;
}
/* static */
bool nsContentUtils::IsCutCopyAllowed(nsIPrincipal* aSubjectPrincipal) {
if (StaticPrefs::dom_allow_cut_copy() &&

View File

@ -2300,6 +2300,16 @@ class nsContentUtils {
*/
static bool IsFocusedContent(const nsIContent* aContent);
/**
* Returns nullptr if requests for fullscreen are allowed in the current
* context. Requests are only allowed if the user initiated them (like with
* a mouse-click or key press), unless this check has been disabled by
* 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* CheckRequestFullscreenAllowed(
mozilla::dom::CallerType aCallerType);
/**
* Returns true if calling execCommand with 'cut' or 'copy' arguments is
* allowed for the given subject principal. These are only allowed if the user
@ -2363,6 +2373,13 @@ 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);

View File

@ -1,50 +0,0 @@
<!DOCTYPE html>
<title>Test for Bug 1129227</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="file_fullscreen-utils.js"></script>
<style>
</style>
<button>Async Request Fullscreen</button>
<script>
function ok(condition, msg) {
opener.ok(condition, "[async] " + msg);
}
function is(a, b, msg) {
opener.is(a, b, "[async] " + msg);
}
function begin() {
SpecialPowers.pushPrefEnv({
"set":[["full-screen-api.allow-trusted-requests-only", true]]
}, startTest);
}
function startTest() {
let button = document.querySelector("button");
button.addEventListener("click", () => {
setTimeout(() => document.body.requestFullscreen(), 0);
});
addFullscreenChangeContinuation("enter", enteredFullscreen);
addFullscreenErrorContinuation(() => {
ok(false, "Failed to enter fullscreen");
exitedFullscreen();
});
synthesizeMouseAtCenter(button, {});
}
function enteredFullscreen() {
is(document.fullscreenElement, document.body, "Entered fullscreen");
addFullscreenChangeContinuation("exit", exitedFullscreen);
document.exitFullscreen();
}
function exitedFullscreen() {
SpecialPowers.popPrefEnv(finish);
}
function finish() {
opener.nextTest();
}
</script>

View File

@ -98,13 +98,12 @@ function testNonTrustContext() {
}
function testLongRunningEventHandler() {
let timeout = SpecialPowers.getIntPref("dom.user_activation.transient.timeout") + 1000;
function longRunningHandler() {
window.removeEventListener("keypress", longRunningHandler);
// Busy loop until transient useractivation is timed out, so our request for
// fullscreen should be rejected.
var end = (new Date()).getTime() + timeout;
// 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;
while ((new Date()).getTime() < end) {
; // Wait...
}

View File

@ -453,7 +453,6 @@ tags = fullscreen
skip-if = toolkit == 'android'
support-files =
file_fullscreen-api.html
file_fullscreen-async.html
file_fullscreen-backdrop.html
file_fullscreen-denied-inner.html
file_fullscreen-denied.html

View File

@ -52,7 +52,6 @@ var gTestWindows = [
prefs: [["dom.security.featurePolicy.enabled", true],
["dom.security.featurePolicy.header.enabled", true],
["dom.security.featurePolicy.webidl.enabled", true]] },
{ test: "file_fullscreen-async.html" },
];
var testWindow = null;

View File

@ -1399,6 +1399,13 @@
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

View File

@ -1,5 +1,4 @@
[fullscreen-report-only.html]
expected: TIMEOUT
[Fullscreen report only mode]
expected: TIMEOUT
expected: FAIL

View File

@ -0,0 +1,5 @@
[element-request-fullscreen.html]
expected: ERROR
[Element#requestFullscreen()]
expected: FAIL