Commit baad1bc4 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Use [RaisesException] for immediate promise rejections in screen_orientation

This is a part of effort for using [RaisesException] when
synchronously rejecting a promise.

It uses [RaisesException] for
//third_party/blink/renderer/modules/screen_orientation.

Bug: 1001114
Change-Id: Ie5d342d6a2a78bb9f44345e7ef61322a188f6205
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986478Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#729652}
parent 3d26a98f
......@@ -148,22 +148,22 @@ void ScreenOrientation::SetAngle(uint16_t angle) {
}
ScriptPromise ScreenOrientation::lock(ScriptState* state,
const AtomicString& lock_string) {
const AtomicString& lock_string,
ExceptionState& exception_state) {
Document* document = GetFrame() ? GetFrame()->GetDocument() : nullptr;
if (!document || !Controller()) {
return ScriptPromise::RejectWithDOMException(
state, MakeGarbageCollected<DOMException>(
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidStateError,
"The object is no longer associated to a document."));
"The object is no longer associated to a document.");
return ScriptPromise();
}
if (document->IsSandboxed(WebSandboxFlags::kOrientationLock)) {
return ScriptPromise::RejectWithDOMException(
state, MakeGarbageCollected<DOMException>(
DOMExceptionCode::kSecurityError,
exception_state.ThrowSecurityError(
"The document is sandboxed and lacks the "
"'allow-orientation-lock' flag."));
"'allow-orientation-lock' flag.");
return ScriptPromise();
}
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(state);
......
......@@ -15,6 +15,7 @@
namespace blink {
class ExceptionState;
class ExecutionContext;
class LocalFrame;
class ScriptPromise;
......@@ -42,7 +43,9 @@ class ScreenOrientation final : public EventTargetWithInlineData,
void SetType(WebScreenOrientationType);
void SetAngle(uint16_t);
ScriptPromise lock(ScriptState*, const AtomicString& orientation);
ScriptPromise lock(ScriptState*,
const AtomicString& orientation,
ExceptionState&);
void unlock();
DEFINE_ATTRIBUTE_EVENT_LISTENER(change, kChange)
......
......@@ -27,7 +27,7 @@ interface ScreenOrientation : EventTarget {
[MeasureAs=ScreenOrientationAngle] readonly attribute unsigned short angle;
[MeasureAs=ScreenOrientationType] readonly attribute DOMString type;
[CallWith=ScriptState, MeasureAs=ScreenOrientationLock] Promise<void> lock(OrientationLockType orientation);
[CallWith=ScriptState, MeasureAs=ScreenOrientationLock, RaisesException] Promise<void> lock(OrientationLockType orientation);
[MeasureAs=ScreenOrientationUnlock] void unlock();
attribute EventHandler onchange;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment