Skip to content
Permalink
Browse files
Add additional tests for beforeload events.
https://bugs.webkit.org/show_bug.cgi?id=41132

Reviewed by Alexey Proskuryakov.

Add tests to verify that the following elements can be removed from the
DOM during beforeload:
    * <object type="application/x-shockwave-flash">
    * <iframe>
    * <img>
    * <script src=""> (non-inline)
    * <video>

* fast/dom/beforeload/remove-flash-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-flash-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-frame-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-frame-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-image-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-image-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-script-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-script-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-video-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-video-in-beforeload-listener.html: Added.



Canonical link: https://commits.webkit.org/52751@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@61744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aestes committed Jun 24, 2010
1 parent 34f8560 commit a3959849900a334bf779514fb7a95247e9e7e144
Showing 11 changed files with 236 additions and 0 deletions.
@@ -1,3 +1,29 @@
2010-06-23 Andy Estes <aestes@apple.com>

Reviewed by Alexey Proskuryakov.

Add additional tests for beforeload events.
https://bugs.webkit.org/show_bug.cgi?id=41132

Add tests to verify that the following elements can be removed from the
DOM during beforeload:
* <object type="application/x-shockwave-flash">
* <iframe>
* <img>
* <script src=""> (non-inline)
* <video>

* fast/dom/beforeload/remove-flash-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-flash-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-frame-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-frame-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-image-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-image-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-script-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-script-in-beforeload-listener.html: Added.
* fast/dom/beforeload/remove-video-in-beforeload-listener-expected.txt: Added.
* fast/dom/beforeload/remove-video-in-beforeload-listener.html: Added.

2010-06-23 Andy Estes <aestes@apple.com>

Reviewed by Joseph Pecoraro.
@@ -0,0 +1,3 @@
This page tests that you can correctly remove a flash object in a beforeload listener without causing a crash.

PASS
@@ -0,0 +1,48 @@
<html>
<head>
<script src="resources/print.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}

var count = 0;
var maxCount = 10;
var timeout = 100;

document.addEventListener("beforeload", function(event) {
if (event.target && event.target.parentElement)
event.target.parentElement.removeChild(event.target);
}, true);
</script>
</head>
<body>
<p>This page tests that you can correctly remove a flash object in a beforeload listener without causing a crash.</p>
<object type="application/x-shockwave-flash" data="../../../plugins/resources/simple_blank.swf"></object>
<div id="console"></div>
<script>
function checkObjectRemoval()
{
if (!document.getElementsByTagName("object").length) {
print("PASS", "green");
if (window.layoutTestController)
layoutTestController.notifyDone();
return;
}

if (++count > maxCount) {
print("FAIL", "red");
if (window.layoutTestController)
layoutTestController.notifyDone();
return;
}

setTimeout("checkObjectRemoval()", timeout);
}

setTimeout("checkObjectRemoval()", timeout);
</script>
</body>
</html>

@@ -0,0 +1,3 @@
This page tests that you can correctly remove an iframe element in its beforeload listener without causing a crash.

PASS
@@ -0,0 +1,25 @@
<html>
<head>
<script src="resources/print.js"></script>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();

document.addEventListener("beforeload", function(event) {
if (event.target && event.target.parentElement)
event.target.parentElement.removeChild(event.target);
}, true);
</script>
</head>
<body>
<p>This page tests that you can correctly remove an iframe element in its beforeload listener without causing a crash.</p>
<iframe src="http://webkit.org"></iframe>
<div id="console"></div>
<script>
if (document.getElementsByTagName("iframe").length)
print("FAIL", "red");
else
print("PASS", "green");
</script>
</body>
</html>
@@ -0,0 +1,3 @@
This page tests that you can correctly remove an img object in a beforeload listener without causing a crash.

PASS
@@ -0,0 +1,47 @@
<html>
<head>
<script src="resources/print.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}

var count = 0;
var maxCount = 10;
var timeout = 100;

document.addEventListener("beforeload", function(event) {
if (event.target && event.target.parentElement)
event.target.parentElement.removeChild(event.target);
}, true);
</script>
</head>
<body>
<p>This page tests that you can correctly remove an img object in a beforeload listener without causing a crash.</p>
<img src="../../images/resources/test-load.jpg">
<div id="console"></div>
<script>
function checkObjectRemoval()
{
if (!document.getElementsByTagName("img").length) {
print("PASS", "green");
if (window.layoutTestController)
layoutTestController.notifyDone();
return;
}

if (++count > maxCount) {
print("FAIL", "red");
if (window.layoutTestController)
layoutTestController.notifyDone();
return;
}

setTimeout("checkObjectRemoval()", timeout);
}

setTimeout("checkObjectRemoval()", timeout);
</script>
</body>
</html>
@@ -0,0 +1,3 @@
This page tests that you can correctly remove a script element in its beforeload listener without causing a crash.

PASS
@@ -0,0 +1,28 @@
<html>
<head>
<script src="resources/print.js"></script>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();

document.addEventListener("beforeload", function(event) {
var scriptElement = document.getElementById("toremove");
if (scriptElement) {
scriptElement.parentElement.removeChild(scriptElement);
event.preventDefault();
}
}, true);
</script>
</head>
<body>
<p>This page tests that you can correctly remove a script element in its beforeload listener without causing a crash.</p>
<script id="toremove" src="resources/fail.js"></script>
<div id="console"></div>
<script>
if (document.getElementById("toremove"))
print("FAIL", "red");
else
print("PASS", "green");
</script>
</body>
</html>
@@ -0,0 +1,3 @@
This page tests that you can correctly remove a video object in a beforeload listener without causing a crash.

PASS
@@ -0,0 +1,47 @@
<html>
<head>
<script src="resources/print.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}

var count = 0;
var maxCount = 10;
var timeout = 100;

document.addEventListener("beforeload", function(event) {
if (event.target && event.target.parentElement)
event.target.parentElement.removeChild(event.target);
}, true);
</script>
</head>
<body>
<p>This page tests that you can correctly remove a video object in a beforeload listener without causing a crash.</p>
<video src="../../../media/content/test.mp4"></video>
<div id="console"></div>
<script>
function checkObjectRemoval()
{
if (!document.getElementsByTagName("video").length) {
print("PASS", "green");
if (window.layoutTestController)
layoutTestController.notifyDone();
return;
}

if (++count > maxCount) {
print("FAIL", "red");
if (window.layoutTestController)
layoutTestController.notifyDone();
return;
}

setTimeout("checkObjectRemoval()", timeout);
}

setTimeout("checkObjectRemoval()", timeout);
</script>
</body>
</html>

0 comments on commit a395984

Please sign in to comment.