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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>script beforescriptexecute/afterscriptexecute events</title>
4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
5 <link rel=help href="https://html.spec.whatwg.org/multipage/#the-script-element" >
6 <script src="../../../../../../resources/testharness.js"></script>
7 <script src="../../../../../../resources/testharnessreport.js"></script>
8 <div id="log"></div>
9 <script>
10 var t1 = async_test("'beforescriptexecute'/'afterscriptexecute' events have be en fired"),
11 t2 = async_test("default prevented 'beforescriptexecute' event aborts scri pt execution"),
12 a = false,
13 b = false;
14
15 var before = function(e) {
16 b = true;
17 test(function(){
18 assert_true(e.isTrusted);
19 assert_true(e.bubbles);
20 assert_true(e.cancelable);
21 }, "'beforescriptexecute' event is trusted, bubbles and is cancelable");
22 };
23
24 var after = function(e) {
25 a = true;
26 test(function(){
27 assert_true(e.isTrusted);
28 assert_true(e.bubbles);
29 assert_false(e.cancelable);
30 }, "'afterscriptexecute' event is trusted, bubbles and isn't cancelable");
31 };
32
33 var prevent_default = function(e) {
34 t2.step(function() {
35 e.preventDefault();
36 assert_true(e.defaultPrevented);
37 });
38 };
39
40 document.body.onload = function() {
41 t1.step(function() {
42 assert_true(a && b);
43 });
44 t1.done();
45 t2.done();
46 };
47 </script>
48 <script onbeforescriptexecute=before(event) onafterscriptexecute=after(event)>
49 document.querySelector("script");
50 </script>
51 <script onbeforescriptexecute=prevent_default(event)>
52 t2.step(function() {
53 assert_unreached("script execution not aborted by default prevented 'befores criptexecute' event");
54 });
55 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698