Add tests for removing the parent/child of the fullscreen element

The parent test would fail if Fullscreen::elementRemoved() were only
called for the top-most removed element.

The child test would require a more serious misinterpretation of "in
fullscreen element stack".

BUG=383813

Review URL: https://codereview.chromium.org/479113003

git-svn-id: svn://svn.chromium.org/blink/trunk@180700 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/LayoutTests/fullscreen/api/element-request-fullscreen-top.html b/third_party/WebKit/LayoutTests/fullscreen/api/element-request-fullscreen-top.html
index 36cb40f..260b8631 100644
--- a/third_party/WebKit/LayoutTests/fullscreen/api/element-request-fullscreen-top.html
+++ b/third_party/WebKit/LayoutTests/fullscreen/api/element-request-fullscreen-top.html
@@ -17,7 +17,7 @@
         trusted_event(t.step_func(function()
         {
             top.requestFullscreen();
-            // An fullscreenerror event would be fired after an async section
+            // A fullscreenerror event would be fired after an async section
             // and an animation frame task, so wait until after that.
             setTimeout(requestAnimationFrame.bind(null, t.step_func_done()), 0);
         }), top);
diff --git a/third_party/WebKit/LayoutTests/fullscreen/model/remove-child.html b/third_party/WebKit/LayoutTests/fullscreen/model/remove-child.html
new file mode 100644
index 0000000..ba4a122
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fullscreen/model/remove-child.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<title>Remove the child of the fullscreen element</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../trusted-event.js"></script>
+<div id="log"></div>
+<div id="parent">
+    <div></div>
+</div>
+<script>
+async_test(function(t)
+{
+    var parent = document.getElementById("parent");
+    trusted_request(parent);
+    document.onfullscreenchange = t.step_func(function()
+    {
+        assert_equals(document.fullscreenElement, parent);
+        while (parent.firstChild) {
+            parent.firstChild.remove();
+        }
+        document.onfullscreenchange = t.unreached_func("fullscreenchange event");
+        // A fullscreenchange event would be fired after an async section
+        // and an animation frame task, so wait until after that.
+        setTimeout(requestAnimationFrame.bind(null, t.step_func_done()), 0);
+    });
+});
+</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/model/remove-parent.html b/third_party/WebKit/LayoutTests/fullscreen/model/remove-parent.html
new file mode 100644
index 0000000..540fae60
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fullscreen/model/remove-parent.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<title>Remove the parent of the fullscreen element</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../trusted-event.js"></script>
+<div id="log"></div>
+<div>
+    <div id="child"></div>
+</div>
+<script>
+async_test(function(t)
+{
+    var child = document.getElementById("child");
+    trusted_request(child);
+    document.onfullscreenchange = t.step_func(function()
+    {
+        assert_equals(document.fullscreenElement, child);
+        child.parentNode.remove();
+        document.onfullscreenchange = t.step_func(function()
+        {
+            assert_equals(document.fullscreenElement, null);
+            t.done();
+        });
+    });
+});
+</script>