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

Unified Diff: LayoutTests/imported/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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: LayoutTests/imported/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html
diff --git a/LayoutTests/imported/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html b/LayoutTests/imported/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html
new file mode 100644
index 0000000000000000000000000000000000000000..d653d832b6885742a5278ebfa8d2f3da8f73895c
--- /dev/null
+++ b/LayoutTests/imported/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>script beforescriptexecute/afterscriptexecute events</title>
+<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
+<link rel=help href="https://html.spec.whatwg.org/multipage/#the-script-element">
+<script src="../../../../../../resources/testharness.js"></script>
+<script src="../../../../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+ var t1 = async_test("'beforescriptexecute'/'afterscriptexecute' events have been fired"),
+ t2 = async_test("default prevented 'beforescriptexecute' event aborts script execution"),
+ a = false,
+ b = false;
+
+ var before = function(e) {
+ b = true;
+ test(function(){
+ assert_true(e.isTrusted);
+ assert_true(e.bubbles);
+ assert_true(e.cancelable);
+ }, "'beforescriptexecute' event is trusted, bubbles and is cancelable");
+ };
+
+ var after = function(e) {
+ a = true;
+ test(function(){
+ assert_true(e.isTrusted);
+ assert_true(e.bubbles);
+ assert_false(e.cancelable);
+ }, "'afterscriptexecute' event is trusted, bubbles and isn't cancelable");
+ };
+
+ var prevent_default = function(e) {
+ t2.step(function() {
+ e.preventDefault();
+ assert_true(e.defaultPrevented);
+ });
+ };
+
+ document.body.onload = function() {
+ t1.step(function() {
+ assert_true(a && b);
+ });
+ t1.done();
+ t2.done();
+ };
+</script>
+<script onbeforescriptexecute=before(event) onafterscriptexecute=after(event)>
+ document.querySelector("script");
+</script>
+<script onbeforescriptexecute=prevent_default(event)>
+ t2.step(function() {
+ assert_unreached("script execution not aborted by default prevented 'beforescriptexecute' event");
+ });
+</script>

Powered by Google App Engine
This is Rietveld 408576698