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) { ...@@ -148,22 +148,22 @@ void ScreenOrientation::SetAngle(uint16_t angle) {
} }
ScriptPromise ScreenOrientation::lock(ScriptState* state, ScriptPromise ScreenOrientation::lock(ScriptState* state,
const AtomicString& lock_string) { const AtomicString& lock_string,
ExceptionState& exception_state) {
Document* document = GetFrame() ? GetFrame()->GetDocument() : nullptr; Document* document = GetFrame() ? GetFrame()->GetDocument() : nullptr;
if (!document || !Controller()) { if (!document || !Controller()) {
return ScriptPromise::RejectWithDOMException( exception_state.ThrowDOMException(
state, MakeGarbageCollected<DOMException>( DOMExceptionCode::kInvalidStateError,
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)) { if (document->IsSandboxed(WebSandboxFlags::kOrientationLock)) {
return ScriptPromise::RejectWithDOMException( exception_state.ThrowSecurityError(
state, MakeGarbageCollected<DOMException>( "The document is sandboxed and lacks the "
DOMExceptionCode::kSecurityError, "'allow-orientation-lock' flag.");
"The document is sandboxed and lacks the " return ScriptPromise();
"'allow-orientation-lock' flag."));
} }
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(state);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace blink { namespace blink {
class ExceptionState;
class ExecutionContext; class ExecutionContext;
class LocalFrame; class LocalFrame;
class ScriptPromise; class ScriptPromise;
...@@ -42,7 +43,9 @@ class ScreenOrientation final : public EventTargetWithInlineData, ...@@ -42,7 +43,9 @@ class ScreenOrientation final : public EventTargetWithInlineData,
void SetType(WebScreenOrientationType); void SetType(WebScreenOrientationType);
void SetAngle(uint16_t); void SetAngle(uint16_t);
ScriptPromise lock(ScriptState*, const AtomicString& orientation); ScriptPromise lock(ScriptState*,
const AtomicString& orientation,
ExceptionState&);
void unlock(); void unlock();
DEFINE_ATTRIBUTE_EVENT_LISTENER(change, kChange) DEFINE_ATTRIBUTE_EVENT_LISTENER(change, kChange)
......
...@@ -27,7 +27,7 @@ interface ScreenOrientation : EventTarget { ...@@ -27,7 +27,7 @@ interface ScreenOrientation : EventTarget {
[MeasureAs=ScreenOrientationAngle] readonly attribute unsigned short angle; [MeasureAs=ScreenOrientationAngle] readonly attribute unsigned short angle;
[MeasureAs=ScreenOrientationType] readonly attribute DOMString type; [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(); [MeasureAs=ScreenOrientationUnlock] void unlock();
attribute EventHandler onchange; 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