Changeset 205319 in webkit
- Timestamp:
- Sep 1, 2016 3:03:10 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205316 r205319 1 2016-09-01 Devin Rousso <dcrousso+webkit@gmail.com> 2 3 Web Inspector: add Object.awaitEvent which is like singleFireEventListener but returns a promise 4 https://bugs.webkit.org/show_bug.cgi?id=161451 5 6 Reviewed by Brian Burg. 7 8 * inspector/unit-tests/object-expected.txt: 9 * inspector/unit-tests/object.html: 10 1 11 2016-09-01 Ryosuke Niwa <rniwa@webkit.org> 2 12 -
trunk/LayoutTests/inspector/unit-tests/object-expected.txt
r195442 r205319 3 3 4 4 == Running test suite: Object 5 -- Running test case: Events propagation5 -- Running test case: WebInspector.Object.prototype.dispatchEventToListeners 6 6 Dispatch count: 1 7 7 8 -- Running test case: WebInspector.Object.prototype.awaitEvent 9 PASS: Await event handler should be dispatched just once. 10 Dispatch count: 1 11 -
trunk/LayoutTests/inspector/unit-tests/object.html
r195442 r205319 6 6 function test() 7 7 { 8 let suite = InspectorTest.create SyncSuite("Object");8 let suite = InspectorTest.createAsyncSuite("Object"); 9 9 10 10 suite.addTestCase({ 11 name: " Events propagation",11 name: "WebInspector.Object.prototype.dispatchEventToListeners", 12 12 description: "WebInspector.Object shouldn't dispatch constructor-level events multiple times", 13 test : function() {13 test(resolve, reject) { 14 14 class Parent extends WebInspector.Object {} 15 15 class Child extends Parent {} … … 24 24 25 25 InspectorTest.log("Dispatch count: " + dispatchCount); 26 27 resolve(); 28 } 29 }); 30 31 suite.addTestCase({ 32 name: "WebInspector.Object.prototype.awaitEvent", 33 description: "awaitEvent should only trigger once", 34 test(resolve, reject) { 35 const eventName = "test"; 36 let dispatchCount = 0; 37 38 let object = new WebInspector.Object; 39 40 object.awaitEvent(eventName).then(() => { 41 dispatchCount++; 42 43 InspectorTest.expectThat(dispatchCount === 1, "Await event handler should be dispatched just once."); 44 InspectorTest.log("Dispatch count: " + dispatchCount); 45 46 // Resolve test on second event dispatch. 47 object.awaitEvent(eventName).then(() => { 48 resolve(); 49 }); 50 51 object.dispatchEventToListeners(eventName); 52 }); 53 54 object.dispatchEventToListeners(eventName); 26 55 } 27 56 }); -
trunk/Source/WebInspectorUI/ChangeLog
r205314 r205319 1 2016-09-01 Devin Rousso <dcrousso+webkit@gmail.com> 2 3 Web Inspector: add Object.awaitEvent which is like singleFireEventListener but returns a promise 4 https://bugs.webkit.org/show_bug.cgi?id=161451 5 6 Reviewed by Brian Burg. 7 8 * UserInterface/Base/Object.js: 9 (WebInspector.Object.awaitEvent): 10 (WebInspector.Object.prototype.awaitEvent): 11 1 12 2016-09-01 Nikita Vasilyev <nvasilyev@apple.com> 2 13 -
trunk/Source/WebInspectorUI/UserInterface/Base/Object.js
r202784 r205319 99 99 } 100 100 101 static awaitEvent(eventType) 102 { 103 return new Promise((resolve, reject) => { 104 this.singleFireEventListener(eventType, (event) => resolve(event), null); 105 }); 106 } 107 101 108 // Only used by tests. 102 109 static hasEventListeners(eventType) … … 132 139 singleFireEventListener() { return WebInspector.Object.singleFireEventListener.apply(this, arguments); } 133 140 removeEventListener() { return WebInspector.Object.removeEventListener.apply(this, arguments); } 141 awaitEvent() { return WebInspector.Object.awaitEvent.apply(this, arguments); } 134 142 hasEventListeners() { return WebInspector.Object.hasEventListeners.apply(this, arguments); } 135 143 retainedObjectsWithPrototype() { return WebInspector.Object.retainedObjectsWithPrototype.apply(this, arguments); }
Note: See TracChangeset
for help on using the changeset viewer.