Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2142)

Unified Diff: Source/modules/screen_orientation/ScreenOrientation.cpp

Issue 943483003: Gracefully handle screen.orientation access over unsupported frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch to testharness.js Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/screen_orientation/ScreenOrientation.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientation.cpp b/Source/modules/screen_orientation/ScreenOrientation.cpp
index f9722624331e99b722cb76c08cbe50c1dd840143..896fc9ed6be14dfe863d063544b587ce06267211 100644
--- a/Source/modules/screen_orientation/ScreenOrientation.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientation.cpp
@@ -88,6 +88,12 @@ ScreenOrientation* ScreenOrientation::create(LocalFrame* frame)
{
ASSERT(frame);
+ // Check if the ScreenOrientationController is supported for the
+ // frame. It will not be for all LocalFrames, or the frame may
+ // have been detached.
+ if (!ScreenOrientationController::from(*frame))
+ return nullptr;
+
ScreenOrientation* orientation = new ScreenOrientation(frame);
ASSERT(orientation->controller());
// FIXME: ideally, we would like to provide the ScreenOrientationController

Powered by Google App Engine
This is Rietveld 408576698