browser_markup_events_02.js (2957B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 /* import-globals-from helper_events_test_runner.js */ 4 5 "use strict"; 6 7 // Test that markup view event bubbles show the correct event info for DOM 8 // events. 9 10 const TEST_URL = URL_ROOT_SSL + "doc_markup_events_02.html"; 11 12 loadHelperScript("helper_events_test_runner.js"); 13 14 const TEST_DATA = [ 15 { 16 selector: "#fatarrow", 17 expected: [ 18 { 19 type: "click", 20 filename: TEST_URL + ":42:43", 21 attributes: ["Bubbling"], 22 handler: "() => {\n" + ' alert("Fat arrow without params!");\n' + "}", 23 }, 24 { 25 type: "click", 26 filename: TEST_URL + ":46:43", 27 attributes: ["Bubbling"], 28 handler: "event => {\n" + ' alert("Fat arrow with 1 param!");\n' + "}", 29 }, 30 { 31 type: "click", 32 filename: TEST_URL + ":50:43", 33 attributes: ["Bubbling"], 34 handler: 35 "(event, foo, bar) => {\n" + 36 ' alert("Fat arrow with 3 params!");\n' + 37 "}", 38 }, 39 { 40 type: "click", 41 filename: TEST_URL + ":54:43", 42 attributes: ["Bubbling"], 43 handler: "b => b", 44 }, 45 ], 46 }, 47 { 48 selector: "#bound", 49 expected: [ 50 { 51 type: "click", 52 filename: TEST_URL + ":65:32", 53 attributes: ["Bubbling"], 54 handler: "function(event) {\n" + ' alert("Bound event");\n' + "}", 55 }, 56 ], 57 }, 58 { 59 selector: "#boundhe", 60 expected: [ 61 { 62 type: "click", 63 filename: TEST_URL + ":89:19", 64 attributes: ["Bubbling"], 65 handler: "function() {\n" + ' alert("boundHandleEvent");\n' + "}", 66 }, 67 ], 68 }, 69 { 70 selector: "#comment-inline", 71 expected: [ 72 { 73 type: "click", 74 filename: TEST_URL + ":95:47", 75 attributes: ["Bubbling"], 76 handler: 77 "function functionProceededByInlineComment() {\n" + 78 ' alert("comment-inline");\n' + 79 "}", 80 }, 81 ], 82 }, 83 { 84 selector: "#comment-streaming", 85 expected: [ 86 { 87 type: "click", 88 filename: TEST_URL + ":100:50", 89 attributes: ["Bubbling"], 90 handler: 91 "function functionProceededByStreamingComment() {\n" + 92 ' alert("comment-streaming");\n' + 93 "}", 94 }, 95 ], 96 }, 97 { 98 selector: "#anon-object-method", 99 expected: [ 100 { 101 type: "click", 102 filename: TEST_URL + ":75:34", 103 attributes: ["Bubbling"], 104 handler: "function() {\n" + ' alert("obj.anonObjectMethod");\n' + "}", 105 }, 106 ], 107 }, 108 { 109 selector: "#object-method", 110 expected: [ 111 { 112 type: "click", 113 filename: TEST_URL + ":79:34", 114 attributes: ["Bubbling"], 115 handler: "function kay() {\n" + ' alert("obj.objectMethod");\n' + "}", 116 }, 117 ], 118 }, 119 ]; 120 121 add_task(async function () { 122 await runEventPopupTests(TEST_URL, TEST_DATA); 123 });