Title: [104838] trunk
Revision
104838
Author
[email protected]
Date
2012-01-12 11:15:27 -0800 (Thu, 12 Jan 2012)

Log Message

Emit an error event when a request to enter full-screen is rejected.
https://bugs.webkit.org/show_bug.cgi?id=62320

Reviewed by Eric Carlson.

Source/WebCore:

Tests: fullscreen/full-screen-request-rejected.html
       fullscreen/full-screen-request-removed.html

When a request to enter full-screen is rejected, emit an event
(webkitfullscreenerror) in response.  But emit the event during the next
trip through the run-loop, like the webkitfullscreenchange event, and so a new
timer and queue are necessary.

* dom/Document.cpp:
(WebCore::Document::requestFullScreenForElement): Emit the error event
    if the request does not pass all our requirements.
* dom/Document.h: Add new ivars.
* dom/Document.idl: Add support for setting an onfullscreenerror attribute.
* dom/Element.h: Ditto.
* dom/Element.idl: Ditto.
* dom/EventNames.h: Add the name for the error event.

LayoutTests:

* fullscreen/full-screen-iframe-not-allowed-expected.txt:
* fullscreen/full-screen-iframe-not-allowed.html:
* fullscreen/full-screen-request-rejected-expected.txt: Added.
* fullscreen/full-screen-request-rejected.html: Added.
* fullscreen/full-screen-request-removed-expected: Added.
* fullscreen/full-screen-request-removed.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104837 => 104838)


--- trunk/LayoutTests/ChangeLog	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/LayoutTests/ChangeLog	2012-01-12 19:15:27 UTC (rev 104838)
@@ -1,3 +1,17 @@
+2011-09-26  Jer Noble  <[email protected]>
+
+        Emit an error event when a request to enter full-screen is rejected.
+        https://bugs.webkit.org/show_bug.cgi?id=62320
+
+        Reviewed by Eric Carlson.
+
+        * fullscreen/full-screen-iframe-not-allowed-expected.txt:
+        * fullscreen/full-screen-iframe-not-allowed.html:
+        * fullscreen/full-screen-request-rejected-expected.txt: Added.
+        * fullscreen/full-screen-request-rejected.html: Added.
+        * fullscreen/full-screen-request-removed-expected: Added.
+        * fullscreen/full-screen-request-removed.html: Added.
+
 2012-01-11  Gavin Barraclough  <[email protected]>
 
         Allow accessor get/set property to be set to undefined

Modified: trunk/LayoutTests/fullscreen/full-screen-iframe-not-allowed-expected.txt (104837 => 104838)


--- trunk/LayoutTests/fullscreen/full-screen-iframe-not-allowed-expected.txt	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/LayoutTests/fullscreen/full-screen-iframe-not-allowed-expected.txt	2012-01-12 19:15:27 UTC (rev 104838)
@@ -2,6 +2,7 @@
 
 To test manually, click the "Go full screen" button - the page should not enter full screen mode.
 
+EVENT(webkitfullscreenerror)
 SUCCEED - did not enter full screen!
 END OF TEST
 

Modified: trunk/LayoutTests/fullscreen/full-screen-iframe-not-allowed.html (104837 => 104838)


--- trunk/LayoutTests/fullscreen/full-screen-iframe-not-allowed.html	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/LayoutTests/fullscreen/full-screen-iframe-not-allowed.html	2012-01-12 19:15:27 UTC (rev 104838)
@@ -11,13 +11,11 @@
             endTest();
     });
 
-    runWithKeyDown(function() {
+    waitForEventAndEnd(frame.contentDocument, 'webkitfullscreenerror', function() {
+        consoleWrite("SUCCEED - did not enter full screen!");
+    });
 
-        setTimeout(function() { 
-            consoleWrite("SUCCEED - did not enter full screen!"); 
-            endTest(); 
-        }, 50);
-
+    runWithKeyDown(function() {
         frame.contentDocument.documentElement.webkitRequestFullScreen();
     });
 }

Added: trunk/LayoutTests/fullscreen/full-screen-request-rejected-expected.txt (0 => 104838)


--- trunk/LayoutTests/fullscreen/full-screen-request-rejected-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/full-screen-request-rejected-expected.txt	2012-01-12 19:15:27 UTC (rev 104838)
@@ -0,0 +1,3 @@
+EVENT(webkitfullscreenerror)
+END OF TEST
+This tests that a full-screen request which is not user-initiated will be rejected.

Added: trunk/LayoutTests/fullscreen/full-screen-request-rejected.html (0 => 104838)


--- trunk/LayoutTests/fullscreen/full-screen-request-rejected.html	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/full-screen-request-rejected.html	2012-01-12 19:15:27 UTC (rev 104838)
@@ -0,0 +1,16 @@
+<body>
+<script src=""
+<div>This tests that a full-screen request which is not user-initiated will be rejected.
+<script>
+    // Bail out early if the full screen API is not enabled or is missing:
+    if (Element.prototype.webkitRequestFullScreen == undefined) {
+        logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
+        endTest();
+    } else {
+        waitForEvent(document, 'webkitfullscreenchange', function() {
+           logResult("Entered full screen.", false); 
+        });
+        waitForEventAndEnd(document, 'webkitfullscreenerror');
+        document.documentElement.webkitRequestFullScreen();
+    }
+</script>

Added: trunk/LayoutTests/fullscreen/full-screen-request-removed-expected.txt (0 => 104838)


--- trunk/LayoutTests/fullscreen/full-screen-request-removed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/full-screen-request-removed-expected.txt	2012-01-12 19:15:27 UTC (rev 104838)
@@ -0,0 +1,10 @@
+Test for bug 62320: Emit an error event when a request to enter full-screen is rejected.
+
+Tests that the document is still messaged if the element requesting full screen is removed before the event is generated.
+
+Added child element.
+Removed child element.
+EVENT(webkitfullscreenerror)
+SUCCEED - did not enter full screen!
+END OF TEST
+

Added: trunk/LayoutTests/fullscreen/full-screen-request-removed.html (0 => 104838)


--- trunk/LayoutTests/fullscreen/full-screen-request-removed.html	                        (rev 0)
+++ trunk/LayoutTests/fullscreen/full-screen-request-removed.html	2012-01-12 19:15:27 UTC (rev 104838)
@@ -0,0 +1,24 @@
+<p>Test for <a href="" 62320</a>: 
+Emit an error event when a request to enter full-screen is rejected.</p>
+<p>Tests that the document is still messaged if the element requesting full screen is removed before the event is generated.</p>
+<script src=""
+<script>
+function runTest() {
+    waitForEventAndEnd(document, 'webkitfullscreenchange', function() { 
+            consoleWrite("FAIL - entered full screen!"); 
+    });
+
+    waitForEventAndEnd(document, 'webkitfullscreenerror', function() {
+        consoleWrite("SUCCEED - did not enter full screen!");
+    });
+
+    var div = document.createElement('div');
+    document.documentElement.appendChild(div);
+    consoleWrite("Added child element.")
+    div.webkitRequestFullScreen();
+    document.documentElement.removeChild(div);
+    consoleWrite("Removed child element.")
+}
+
+runTest();
+</script>

Modified: trunk/Source/WebCore/ChangeLog (104837 => 104838)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 19:15:27 UTC (rev 104838)
@@ -1,3 +1,27 @@
+2011-09-26  Jer Noble  <[email protected]>
+
+        Emit an error event when a request to enter full-screen is rejected.
+        https://bugs.webkit.org/show_bug.cgi?id=62320
+
+        Reviewed by Eric Carlson.
+
+        Tests: fullscreen/full-screen-request-rejected.html
+               fullscreen/full-screen-request-removed.html
+
+        When a request to enter full-screen is rejected, emit an event 
+        (webkitfullscreenerror) in response.  But emit the event during the next
+        trip through the run-loop, like the webkitfullscreenchange event, and so a new
+        timer and queue are necessary.
+
+        * dom/Document.cpp:
+        (WebCore::Document::requestFullScreenForElement): Emit the error event
+            if the request does not pass all our requirements.
+        * dom/Document.h: Add new ivars.
+        * dom/Document.idl: Add support for setting an onfullscreenerror attribute.
+        * dom/Element.h: Ditto.
+        * dom/Element.idl: Ditto.
+        * dom/EventNames.h: Add the name for the error event.
+
 2012-01-12  Beth Dakin  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=76133

Modified: trunk/Source/WebCore/dom/Document.cpp (104837 => 104838)


--- trunk/Source/WebCore/dom/Document.cpp	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-01-12 19:15:27 UTC (rev 104838)
@@ -1846,6 +1846,7 @@
     m_eventQueue->close();
 #if ENABLE(FULLSCREEN_API)
     m_fullScreenChangeEventTargetQueue.clear();
+    m_fullScreenErrorEventTargetQueue.clear();
 #endif
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
@@ -5011,23 +5012,29 @@
 
 void Document::requestFullScreenForElement(Element* element, unsigned short flags, FullScreenCheckType checkType)
 {
-    if (!page() || !page()->settings()->fullScreenEnabled())
-        return;
+    do {
+        if (!page() || !page()->settings()->fullScreenEnabled())
+            break;
 
-    if (!element)
-        element = documentElement();
-    
-    if (checkType == EnforceIFrameAllowFulScreenRequirement && !fullScreenIsAllowedForElement(element))
+        if (!element)
+            element = documentElement();
+        
+        if (checkType == EnforceIFrameAllowFulScreenRequirement && !fullScreenIsAllowedForElement(element))
+            break;
+        
+        if (!ScriptController::processingUserGesture())
+            break;
+        
+        if (!page()->chrome()->client()->supportsFullScreenForElement(element, flags & Element::ALLOW_KEYBOARD_INPUT))
+            break;
+        
+        m_areKeysEnabledInFullScreen = flags & Element::ALLOW_KEYBOARD_INPUT;
+        page()->chrome()->client()->enterFullScreenForElement(element);
         return;
+    } while (0);
     
-    if (!ScriptController::processingUserGesture())
-        return;
-    
-    if (!page()->chrome()->client()->supportsFullScreenForElement(element, flags & Element::ALLOW_KEYBOARD_INPUT))
-        return;
-    
-    m_areKeysEnabledInFullScreen = flags & Element::ALLOW_KEYBOARD_INPUT;
-    page()->chrome()->client()->enterFullScreenForElement(element);
+    m_fullScreenErrorEventTargetQueue.append(element ? element : documentElement());
+    m_fullScreenChangeDelayTimer.startOneShot(0);
 }
 
 void Document::webkitCancelFullScreen()
@@ -5195,6 +5202,18 @@
         
         element->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
     }
+
+    while (!m_fullScreenErrorEventTargetQueue.isEmpty()) {
+        RefPtr<Element> element = m_fullScreenErrorEventTargetQueue.takeFirst();
+        if (!element)
+            element = documentElement();
+        
+        // If the element was removed from our tree, also message the documentElement.
+        if (!contains(element.get()))
+            m_fullScreenErrorEventTargetQueue.append(documentElement());
+        
+        element->dispatchEvent(Event::create(eventNames().webkitfullscreenerrorEvent, true, false));
+    }
 }
 
 void Document::fullScreenElementRemoved()

Modified: trunk/Source/WebCore/dom/Document.h (104837 => 104838)


--- trunk/Source/WebCore/dom/Document.h	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/dom/Document.h	2012-01-12 19:15:27 UTC (rev 104838)
@@ -316,6 +316,7 @@
 #endif
 #if ENABLE(FULLSCREEN_API)
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenerror);
 #endif
 #if ENABLE(PAGE_VISIBILITY_API)
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitvisibilitychange);
@@ -1419,6 +1420,7 @@
     RenderFullScreen* m_fullScreenRenderer;
     Timer<Document> m_fullScreenChangeDelayTimer;
     Deque<RefPtr<Element> > m_fullScreenChangeEventTargetQueue;
+    Deque<RefPtr<Element> > m_fullScreenErrorEventTargetQueue;
     bool m_isAnimatingFullScreen;
     LayoutRect m_savedPlaceholderFrameRect;
     RefPtr<RenderStyle> m_savedPlaceholderRenderStyle;

Modified: trunk/Source/WebCore/dom/Document.idl (104837 => 104838)


--- trunk/Source/WebCore/dom/Document.idl	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/dom/Document.idl	2012-01-12 19:15:27 UTC (rev 104838)
@@ -321,6 +321,7 @@
         attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
         attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
         attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange;
+        attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenerror;
 #endif
 
 #if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS

Modified: trunk/Source/WebCore/dom/Element.h (104837 => 104838)


--- trunk/Source/WebCore/dom/Element.h	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/dom/Element.h	2012-01-12 19:15:27 UTC (rev 104838)
@@ -107,6 +107,7 @@
 #endif
 #if ENABLE(FULLSCREEN_API)
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenerror);
 #endif
 
     bool hasAttribute(const QualifiedName&) const;

Modified: trunk/Source/WebCore/dom/Element.idl (104837 => 104838)


--- trunk/Source/WebCore/dom/Element.idl	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/dom/Element.idl	2012-01-12 19:15:27 UTC (rev 104838)
@@ -204,6 +204,7 @@
         attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
         attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
         attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange;
+        attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenerror;
 #endif
     };
 

Modified: trunk/Source/WebCore/dom/EventNames.h (104837 => 104838)


--- trunk/Source/WebCore/dom/EventNames.h	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/dom/EventNames.h	2012-01-12 19:15:27 UTC (rev 104838)
@@ -181,6 +181,7 @@
     macro(loadend) \
     \
     macro(webkitfullscreenchange) \
+    macro(webkitfullscreenerror) \
     \
     macro(webkitspeechchange) \
     \

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (104837 => 104838)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2012-01-12 19:15:27 UTC (rev 104838)
@@ -246,6 +246,7 @@
 onwebkitbeginfullscreen
 onwebkitendfullscreen
 onwebkitfullscreenchange
+onwebkitfullscreenerror
 onwebkittransitionend
 open
 optimum

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (104837 => 104838)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2012-01-12 19:06:35 UTC (rev 104837)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2012-01-12 19:15:27 UTC (rev 104838)
@@ -330,6 +330,8 @@
 #if ENABLE(FULLSCREEN_API)
     } else if (attr->name() == onwebkitfullscreenchangeAttr) {
         setAttributeEventListener(eventNames().webkitfullscreenchangeEvent, createAttributeEventListener(this, attr));
+    } else if (attr->name() == onwebkitfullscreenerrorAttr) {
+        setAttributeEventListener(eventNames().webkitfullscreenerrorEvent, createAttributeEventListener(this, attr));
 #endif
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to