Changeset 211594 in webkit
- Timestamp:
- Feb 2, 2017 2:07:28 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 37 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r211593 r211594 1 2017-02-02 Joseph Pecoraro <pecoraro@apple.com> 2 3 Support Performance API (performance.now(), UserTiming) in Workers 4 https://bugs.webkit.org/show_bug.cgi?id=167717 5 6 Reviewed by Ryosuke Niwa. 7 8 * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: 9 Updated now that Performance classes are in Workers. 10 11 * performance-api/performance-now-api-expected.txt: Added. 12 * performance-api/performance-now-api.html: Added. 13 * performance-api/performance-now-time-origin-in-worker-expected.txt: Added. 14 * performance-api/performance-now-time-origin-in-worker.html: Added. 15 New tests to cover performance.now. 16 17 * performance-api/performance-mark-name-expected.txt: Added. 18 * performance-api/performance-mark-name.html: Added. 19 * performance-api/resources/mark-name.js: Added. 20 * performance-api/resources/user-timing-api.js: Added. 21 * performance-api/user-timing-apis-expected.txt: Added. 22 * performance-api/user-timing-apis.html: Added. 23 New tests to cover user-timing and performance.mark behavior. 24 25 * performance-api/performance-observer-api-expected.txt: 26 * performance-api/performance-observer-api.html: 27 * performance-api/performance-observer-basic-expected.txt: 28 * performance-api/performance-observer-basic.html: 29 * performance-api/performance-timeline-api-expected.txt: 30 * performance-api/performance-timeline-api.html: 31 * performance-api/resources/now-api.js: Added. 32 * performance-api/resources/observer-api.js: Copied from LayoutTests/performance-api/performance-observer-api.html. 33 * performance-api/resources/observer-basic.js: Copied from LayoutTests/performance-api/performance-observer-basic.html. 34 * performance-api/resources/time-origin-in-worker.js: Added. 35 * performance-api/resources/timeline-api.js: Copied from LayoutTests/performance-api/performance-timeline-api.html. 36 Update some of the existing tests to check in a Document and Worker. 37 38 * imported/w3c/web-platform-tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes-expected.txt: 39 Minor progression. 40 1 41 2017-02-02 Ryan Haddad <ryanhaddad@apple.com> 2 42 -
trunk/LayoutTests/imported/w3c/web-platform-tests/user-timing/test_user_timing_mark_and_measure_exception_when_invoke_with_timing_attributes-expected.txt
r211333 r211594 6 6 PASS window.performance is defined 7 7 FAIL performance.mark and performance.measure should throw if used with timing attribute values assert_throws: function "function () { window.performance.measure(timingAttributes..." did not throw 8 FAIL performance.mark and performance.measure should not throw if used with timing attribute values in workers Can't find variable: performance 8 PASS performance.mark and performance.measure should not throw if used with timing attribute values in workers 9 9 -
trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
r209598 r211594 195 195 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Object').enumerable is false 196 196 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Object').configurable is true 197 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Performance').value is Performance 198 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Performance').hasOwnProperty('get') is false 199 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Performance').hasOwnProperty('set') is false 200 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Performance').enumerable is false 201 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Performance').configurable is true 202 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceEntry').value is PerformanceEntry 203 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceEntry').hasOwnProperty('get') is false 204 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceEntry').hasOwnProperty('set') is false 205 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceEntry').enumerable is false 206 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceEntry').configurable is true 207 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMark').value is PerformanceMark 208 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMark').hasOwnProperty('get') is false 209 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMark').hasOwnProperty('set') is false 210 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMark').enumerable is false 211 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMark').configurable is true 212 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMeasure').value is PerformanceMeasure 213 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMeasure').hasOwnProperty('get') is false 214 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMeasure').hasOwnProperty('set') is false 215 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMeasure').enumerable is false 216 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceMeasure').configurable is true 217 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserver').value is PerformanceObserver 218 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserver').hasOwnProperty('get') is false 219 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserver').hasOwnProperty('set') is false 220 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserver').enumerable is false 221 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserver').configurable is true 222 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserverEntryList').value is PerformanceObserverEntryList 223 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserverEntryList').hasOwnProperty('get') is false 224 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserverEntryList').hasOwnProperty('set') is false 225 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserverEntryList').enumerable is false 226 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'PerformanceObserverEntryList').configurable is true 197 227 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ProgressEvent').value is ProgressEvent 198 228 PASS [Worker] Object.getOwnPropertyDescriptor(global, 'ProgressEvent').hasOwnProperty('get') is false -
trunk/LayoutTests/performance-api/performance-observer-api-expected.txt
r211406 r211594 30 30 PASS PerformanceObserverEntryList.prototype.getEntriesByName is defined. 31 31 PASS new PerformanceObserverEntryList() threw exception TypeError: function is not a constructor (evaluating 'new PerformanceObserverEntryList()'). 32 33 Starting worker: resources/observer-api.js 34 [Worker] PerformanceObserver 35 PASS [Worker] PerformanceObserver is defined. 36 PASS [Worker] PerformanceObserver.prototype.observe is defined. 37 PASS [Worker] PerformanceObserver.prototype.disconnect is defined. 38 PASS [Worker] PerformanceObserver() threw exception TypeError: Constructor requires 'new' operator. 39 PASS [Worker] new PerformanceObserver() threw exception TypeError: Not enough arguments. 40 PASS [Worker] new PerformanceObserver(1) threw exception TypeError: Argument 1 ('callback') to the PerformanceObserver constructor must be a function. 41 PASS [Worker] observer = new PerformanceObserver(function() {}) did not throw exception. 42 PASS [Worker] observer.observe() threw exception TypeError: Not enough arguments. 43 PASS [Worker] observer.observe("mark") threw exception TypeError: Type error. 44 PASS [Worker] observer.observe({}) threw exception TypeError: Member PerformanceObserverInit.entryTypes is required and must be an instance of sequence. 45 PASS [Worker] observer.observe({entryTypes:"mark"}) threw exception TypeError: Value is not a sequence. 46 PASS [Worker] observer.observe({entryTypes:[]}) threw exception TypeError: entryTypes cannot be an empty list. 47 PASS [Worker] observer.observe({entryTypes:["not-real"]}) threw exception TypeError: entryTypes contained only unsupported types. 48 PASS [Worker] observer.observe({entryTypes:["mark"]}) did not throw exception. 49 PASS [Worker] observer.observe({entryTypes:["mark", "not-real"]}) did not throw exception. 50 PASS [Worker] observer.observe({entryTypes:["mark", "measure"]}) did not throw exception. 51 PASS [Worker] observer.disconnect() did not throw exception. 52 PASS [Worker] observer.disconnect() did not throw exception. 53 [Worker] 54 [Worker] PerformanceObserverEntryList 55 PASS [Worker] PerformanceObserverEntryList is defined. 56 PASS [Worker] PerformanceObserverEntryList.prototype.getEntries is defined. 57 PASS [Worker] PerformanceObserverEntryList.prototype.getEntriesByType is defined. 58 PASS [Worker] PerformanceObserverEntryList.prototype.getEntriesByName is defined. 59 PASS [Worker] new PerformanceObserverEntryList() threw exception TypeError: function is not a constructor (evaluating 'new PerformanceObserverEntryList()'). 32 60 PASS successfullyParsed is true 33 61 -
trunk/LayoutTests/performance-api/performance-observer-api.html
r211406 r211594 5 5 </head> 6 6 <body> 7 <script src="resources/observer-api.js"></script> 7 8 <script> 8 description("Basic Interface test for PerformanceObserver APIs.");9 10 debug("PerformanceObserver");11 shouldBeDefined(`PerformanceObserver`);12 shouldBeDefined(`PerformanceObserver.prototype.observe`);13 shouldBeDefined(`PerformanceObserver.prototype.disconnect`);14 shouldThrow(`PerformanceObserver()`);15 shouldThrow(`new PerformanceObserver()`);16 shouldThrow(`new PerformanceObserver(1)`);17 shouldNotThrow(`observer = new PerformanceObserver(function() {})`);18 shouldThrow(`observer.observe()`);19 shouldThrow(`observer.observe("mark")`);20 shouldThrow(`observer.observe({})`);21 shouldThrow(`observer.observe({entryTypes:"mark"})`);22 shouldThrow(`observer.observe({entryTypes:[]})`);23 shouldThrow(`observer.observe({entryTypes:["not-real"]})`);24 shouldNotThrow(`observer.observe({entryTypes:["mark"]})`);25 shouldNotThrow(`observer.observe({entryTypes:["mark", "not-real"]})`);26 shouldNotThrow(`observer.observe({entryTypes:["mark", "measure"]})`);27 shouldNotThrow(`observer.disconnect()`);28 shouldNotThrow(`observer.disconnect()`);29 30 9 debug(""); 31 debug("PerformanceObserverEntryList"); 32 shouldBeDefined(`PerformanceObserverEntryList`); 33 shouldBeDefined(`PerformanceObserverEntryList.prototype.getEntries`); 34 shouldBeDefined(`PerformanceObserverEntryList.prototype.getEntriesByType`); 35 shouldBeDefined(`PerformanceObserverEntryList.prototype.getEntriesByName`); 36 shouldThrow(`new PerformanceObserverEntryList()`); 10 let worker = startWorker("resources/observer-api.js"); 37 11 </script> 38 12 <script src="../resources/js-test-post.js"></script> -
trunk/LayoutTests/performance-api/performance-observer-basic-expected.txt
r211406 r211594 47 47 PASS list.getEntriesByName(null, "mark").length === 0 is true 48 48 PASS list.getEntriesByName(undefined, "mark").length === 0 is true 49 50 Starting worker: resources/observer-basic.js 51 [Worker] Inside PerformanceObserver callback 52 PASS [Worker] argumentsLength === 2 is true 53 PASS [Worker] list instanceof PerformanceObserverEntryList is true 54 PASS [Worker] obs instanceof PerformanceObserver is true 55 PASS [Worker] obs === observer is true 56 FAIL [Worker] thisObject instanceof PerformanceObserver should be true. Was false. 57 FAIL [Worker] thisObject === observer should be true. Was false. 58 [Worker] 59 [Worker] PerformanceObserverEntryList APIs 60 PASS [Worker] list.getEntries() instanceof Array is true 61 PASS [Worker] list.getEntries().length === 2 is true 62 PASS [Worker] list.getEntries()[0] instanceof PerformanceEntry is true 63 PASS [Worker] list.getEntries()[0].name is "mark3" 64 PASS [Worker] list.getEntries()[1].name is "mark4" 65 PASS [Worker] list.getEntries()[0].startTime <= list.getEntries()[1].startTime is true 66 PASS [Worker] list.getEntriesByType() threw exception TypeError: Not enough arguments. 67 PASS [Worker] list.getEntriesByType("not-real").length === 0 is true 68 PASS [Worker] list.getEntriesByType("mark").length === 2 is true 69 PASS [Worker] list.getEntriesByType("mark")[0] instanceof PerformanceEntry is true 70 PASS [Worker] list.getEntriesByType("mark")[0].name is "mark3" 71 PASS [Worker] list.getEntriesByType("mark")[1].name is "mark4" 72 PASS [Worker] list.getEntriesByName() threw exception TypeError: Not enough arguments. 73 PASS [Worker] list.getEntriesByName("not-real").length === 0 is true 74 PASS [Worker] list.getEntriesByName("mark1").length === 0 is true 75 PASS [Worker] list.getEntriesByName("mark3").length === 1 is true 76 PASS [Worker] list.getEntriesByName("mark3")[0] instanceof PerformanceEntry is true 77 PASS [Worker] list.getEntriesByName("mark3")[0].name is "mark3" 78 PASS [Worker] list.getEntriesByName("mark4").length === 1 is true 79 PASS [Worker] list.getEntriesByName("mark4")[0] instanceof PerformanceEntry is true 80 PASS [Worker] list.getEntriesByName("mark4")[0].name is "mark4" 81 PASS [Worker] list.getEntriesByName() threw exception TypeError: Not enough arguments. 82 PASS [Worker] list.getEntriesByName("not-real").length === 0 is true 83 PASS [Worker] list.getEntriesByName("mark1").length === 0 is true 84 PASS [Worker] list.getEntriesByName("mark3").length === 1 is true 85 PASS [Worker] list.getEntriesByName("mark3")[0] instanceof PerformanceEntry is true 86 PASS [Worker] list.getEntriesByName("mark3")[0].name is "mark3" 87 PASS [Worker] list.getEntriesByName("mark4").length === 1 is true 88 PASS [Worker] list.getEntriesByName("mark4")[0] instanceof PerformanceEntry is true 89 PASS [Worker] list.getEntriesByName("mark4")[0].name is "mark4" 90 PASS [Worker] list.getEntriesByName("mark3", "not-real").length === 0 is true 91 PASS [Worker] list.getEntriesByName("mark3", "mark").length === 1 is true 92 PASS [Worker] list.getEntriesByName(null, "mark").length === 0 is true 93 PASS [Worker] list.getEntriesByName(undefined, "mark").length === 0 is true 49 94 PASS successfullyParsed is true 50 95 -
trunk/LayoutTests/performance-api/performance-observer-basic.html
r211406 r211594 5 5 </head> 6 6 <body> 7 <script src="resources/observer-basic.js"></script> 7 8 <script> 8 description("Basic Behavior test for PerformanceObserver APIs."); 9 window.jsTestIsAsync = true; 10 11 // PerformanceObservers that are not actively observing should not fire. 12 let observerNotObserving = new PerformanceObserver(function() { 13 testFailed("PerformanceObserver never registered should not be called"); 14 }); 15 16 let observerNotObserving2 = new PerformanceObserver(function() { 17 testFailed("PerformanceObserver not actively observing should not be called"); 18 }); 19 observerNotObserving2.observe({entryTypes: ["mark"]}); 20 observerNotObserving2.disconnect(); 21 22 // PerformanceObservers for different entry types should not fire. 23 let observerNotMarks = new PerformanceObserver(function() { 24 testFailed("PerformanceObserver observing measures should not be called"); 25 }); 26 27 // Observer sees marks while it is registered. 28 performance.mark("mark1"); 29 window.observer = new PerformanceObserver(function(list, obs) { 30 window.argumentsLength = arguments.length; 31 window.list = list; 32 window.obs = obs; 33 window.thisObject = this; 34 35 debug("Inside PerformanceObserver callback"); 36 shouldBeTrue(`argumentsLength === 2`); 37 shouldBeTrue(`list instanceof PerformanceObserverEntryList`); 38 shouldBeTrue(`obs instanceof PerformanceObserver`); 39 shouldBeTrue(`obs === observer`); 40 // FIXME: <https://webkit.org/b/167549> Invoking generated callback should allow setting the `this` object 41 shouldBeTrue(`thisObject instanceof PerformanceObserver`); 42 shouldBeTrue(`thisObject === observer`); 43 9 function testWorker() { 44 10 debug(""); 45 debug("PerformanceObserverEntryList APIs"); 46 47 shouldBeTrue(`list.getEntries() instanceof Array`); 48 shouldBeTrue(`list.getEntries().length === 2`); 49 shouldBeTrue(`list.getEntries()[0] instanceof PerformanceEntry`); 50 shouldBeEqualToString(`list.getEntries()[0].name`, "mark3"); 51 shouldBeEqualToString(`list.getEntries()[1].name`, "mark4"); 52 shouldBeTrue(`list.getEntries()[0].startTime <= list.getEntries()[1].startTime`); 53 54 shouldThrow(`list.getEntriesByType()`); 55 shouldBeTrue(`list.getEntriesByType("not-real").length === 0`); 56 shouldBeTrue(`list.getEntriesByType("mark").length === 2`); 57 shouldBeTrue(`list.getEntriesByType("mark")[0] instanceof PerformanceEntry`); 58 shouldBeEqualToString(`list.getEntriesByType("mark")[0].name`, "mark3"); 59 shouldBeEqualToString(`list.getEntriesByType("mark")[1].name`, "mark4"); 60 61 shouldThrow(`list.getEntriesByName()`); 62 shouldBeTrue(`list.getEntriesByName("not-real").length === 0`); 63 shouldBeTrue(`list.getEntriesByName("mark1").length === 0`); 64 shouldBeTrue(`list.getEntriesByName("mark3").length === 1`); 65 shouldBeTrue(`list.getEntriesByName("mark3")[0] instanceof PerformanceEntry`); 66 shouldBeEqualToString(`list.getEntriesByName("mark3")[0].name`, "mark3"); 67 shouldBeTrue(`list.getEntriesByName("mark4").length === 1`); 68 shouldBeTrue(`list.getEntriesByName("mark4")[0] instanceof PerformanceEntry`); 69 shouldBeEqualToString(`list.getEntriesByName("mark4")[0].name`, "mark4"); 70 71 shouldThrow(`list.getEntriesByName()`); 72 shouldBeTrue(`list.getEntriesByName("not-real").length === 0`); 73 shouldBeTrue(`list.getEntriesByName("mark1").length === 0`); 74 shouldBeTrue(`list.getEntriesByName("mark3").length === 1`); 75 shouldBeTrue(`list.getEntriesByName("mark3")[0] instanceof PerformanceEntry`); 76 shouldBeEqualToString(`list.getEntriesByName("mark3")[0].name`, "mark3"); 77 shouldBeTrue(`list.getEntriesByName("mark4").length === 1`); 78 shouldBeTrue(`list.getEntriesByName("mark4")[0] instanceof PerformanceEntry`); 79 shouldBeEqualToString(`list.getEntriesByName("mark4")[0].name`, "mark4"); 80 81 shouldBeTrue(`list.getEntriesByName("mark3", "not-real").length === 0`); 82 shouldBeTrue(`list.getEntriesByName("mark3", "mark").length === 1`); 83 shouldBeTrue(`list.getEntriesByName(null, "mark").length === 0`); 84 shouldBeTrue(`list.getEntriesByName(undefined, "mark").length === 0`); 85 86 finishJSTest(); 87 }); 88 performance.mark("mark2"); 89 observer.observe({entryTypes: ["mark"]}); 90 performance.mark("mark3"); 91 performance.mark("mark4"); 11 let worker = startWorker("resources/observer-basic.js"); 12 } 92 13 </script> 93 14 <script src="../resources/js-test-post.js"></script> -
trunk/LayoutTests/performance-api/performance-timeline-api-expected.txt
r211406 r211594 43 43 PASS performance.getEntriesByName("test", "not-real").length === 0 is true 44 44 PASS performance.getEntriesByName("test", "mark").length === 1 is true 45 46 Starting worker: resources/timeline-api.js 47 [Worker] PerformanceEntry 48 PASS [Worker] PerformanceEntry is defined. 49 PASS [Worker] "name" in PerformanceEntry.prototype is true 50 PASS [Worker] "entryType" in PerformanceEntry.prototype is true 51 PASS [Worker] "startTime" in PerformanceEntry.prototype is true 52 PASS [Worker] "duration" in PerformanceEntry.prototype is true 53 PASS [Worker] new PerformanceEntry() threw exception TypeError: function is not a constructor (evaluating 'new PerformanceEntry()'). 54 [Worker] 55 [Worker] Performance extensions 56 PASS [Worker] Performance.prototype.getEntries is defined. 57 PASS [Worker] Performance.prototype.getEntriesByType is defined. 58 PASS [Worker] Performance.prototype.getEntriesByName is defined. 59 PASS [Worker] performance.getEntries() instanceof Array is true 60 PASS [Worker] performance.getEntries().length === 0 is true 61 PASS [Worker] performance.mark("test"); did not throw exception. 62 PASS [Worker] performance.getEntries().length === 1 is true 63 PASS [Worker] performance.getEntries()[0] instanceof PerformanceEntry is true 64 PASS [Worker] performance.getEntries()[0].name is "test" 65 PASS [Worker] performance.getEntries()[0].entryType is "mark" 66 PASS [Worker] typeof performance.getEntries()[0].startTime === "number" is true 67 PASS [Worker] typeof performance.getEntries()[0].duration === "number" is true 68 PASS [Worker] performance.getEntriesByType() threw exception TypeError: Not enough arguments. 69 PASS [Worker] performance.getEntriesByType("not-real").length === 0 is true 70 PASS [Worker] performance.getEntriesByType("mark").length === 1 is true 71 PASS [Worker] performance.getEntriesByType("mark")[0] instanceof PerformanceEntry is true 72 PASS [Worker] performance.getEntriesByType("mark")[0].name is "test" 73 PASS [Worker] performance.getEntriesByType("mark")[0].entryType is "mark" 74 PASS [Worker] typeof performance.getEntriesByType("mark")[0].startTime === "number" is true 75 PASS [Worker] typeof performance.getEntriesByType("mark")[0].duration === "number" is true 76 PASS [Worker] performance.getEntriesByName() threw exception TypeError: Not enough arguments. 77 PASS [Worker] performance.getEntriesByName("not-real").length === 0 is true 78 PASS [Worker] performance.getEntriesByName("test").length === 1 is true 79 PASS [Worker] performance.getEntriesByName("test")[0] instanceof PerformanceEntry is true 80 PASS [Worker] performance.getEntriesByName("test")[0].name is "test" 81 PASS [Worker] performance.getEntriesByName("test")[0].entryType is "mark" 82 PASS [Worker] typeof performance.getEntriesByName("test")[0].startTime === "number" is true 83 PASS [Worker] typeof performance.getEntriesByName("test")[0].duration === "number" is true 84 PASS [Worker] performance.getEntriesByName("test", "not-real").length === 0 is true 85 PASS [Worker] performance.getEntriesByName("test", "mark").length === 1 is true 45 86 PASS successfullyParsed is true 46 87 -
trunk/LayoutTests/performance-api/performance-timeline-api.html
r211406 r211594 5 5 </head> 6 6 <body> 7 <script src="resources/timeline-api.js"></script> 7 8 <script> 8 description("Basic Interface test for performance-timeline APIs.");9 10 debug("PerformanceEntry");11 shouldBeDefined("PerformanceEntry");12 shouldBeTrue(`"name" in PerformanceEntry.prototype`);13 shouldBeTrue(`"entryType" in PerformanceEntry.prototype`);14 shouldBeTrue(`"startTime" in PerformanceEntry.prototype`);15 shouldBeTrue(`"duration" in PerformanceEntry.prototype`);16 shouldThrow(`new PerformanceEntry()`);17 18 // NOTE: The APIs below may be going away. Replaced by PerformanceObserver.19 20 9 debug(""); 21 debug("Performance extensions"); 22 shouldBeDefined(`Performance.prototype.getEntries`); 23 shouldBeDefined(`Performance.prototype.getEntriesByType`); 24 shouldBeDefined(`Performance.prototype.getEntriesByName`); 25 26 shouldBeTrue(`performance.getEntries() instanceof Array`); 27 shouldBeTrue(`performance.getEntries().length === 0`); 28 shouldNotThrow(`performance.mark("test");`); 29 shouldBeTrue(`performance.getEntries().length === 1`); 30 shouldBeTrue(`performance.getEntries()[0] instanceof PerformanceEntry`); 31 shouldBeEqualToString(`performance.getEntries()[0].name`, "test"); 32 shouldBeEqualToString(`performance.getEntries()[0].entryType`, "mark"); 33 shouldBeTrue(`typeof performance.getEntries()[0].startTime === "number"`); 34 shouldBeTrue(`typeof performance.getEntries()[0].duration === "number"`); 35 36 shouldThrow(`performance.getEntriesByType()`); 37 shouldBeTrue(`performance.getEntriesByType("not-real").length === 0`); 38 shouldBeTrue(`performance.getEntriesByType("mark").length === 1`); 39 shouldBeTrue(`performance.getEntriesByType("mark")[0] instanceof PerformanceEntry`); 40 shouldBeEqualToString(`performance.getEntriesByType("mark")[0].name`, "test"); 41 shouldBeEqualToString(`performance.getEntriesByType("mark")[0].entryType`, "mark"); 42 shouldBeTrue(`typeof performance.getEntriesByType("mark")[0].startTime === "number"`); 43 shouldBeTrue(`typeof performance.getEntriesByType("mark")[0].duration === "number"`); 44 45 shouldThrow(`performance.getEntriesByName()`); 46 shouldBeTrue(`performance.getEntriesByName("not-real").length === 0`); 47 shouldBeTrue(`performance.getEntriesByName("test").length === 1`); 48 shouldBeTrue(`performance.getEntriesByName("test")[0] instanceof PerformanceEntry`); 49 shouldBeEqualToString(`performance.getEntriesByName("test")[0].name`, "test"); 50 shouldBeEqualToString(`performance.getEntriesByName("test")[0].entryType`, "mark"); 51 shouldBeTrue(`typeof performance.getEntriesByName("test")[0].startTime === "number"`); 52 shouldBeTrue(`typeof performance.getEntriesByName("test")[0].duration === "number"`); 53 shouldBeTrue(`performance.getEntriesByName("test", "not-real").length === 0`); 54 shouldBeTrue(`performance.getEntriesByName("test", "mark").length === 1`); 10 let worker = startWorker("resources/timeline-api.js"); 55 11 </script> 56 12 <script src="../resources/js-test-post.js"></script> -
trunk/LayoutTests/performance-api/resources/observer-api.js
r211593 r211594 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script src="../resources/js-test-pre.js"></script> 5 </head> 6 <body> 7 <script> 8 description("Basic Interface test for PerformanceObserver APIs."); 1 if (self.importScripts) 2 importScripts("../../resources/js-test-pre.js"); 3 4 if (self.window) 5 description("Basic Interface test for PerformanceObserver APIs."); 9 6 10 7 debug("PerformanceObserver"); … … 35 32 shouldBeDefined(`PerformanceObserverEntryList.prototype.getEntriesByName`); 36 33 shouldThrow(`new PerformanceObserverEntryList()`); 37 </script> 38 <script src="../resources/js-test-post.js"></script> 39 </body> 40 </html> 34 35 if (self.importScripts) 36 finishJSTest(); -
trunk/LayoutTests/performance-api/resources/observer-basic.js
r211593 r211594 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script src="../resources/js-test-pre.js"></script> 5 </head> 6 <body> 7 <script> 8 description("Basic Behavior test for PerformanceObserver APIs."); 9 window.jsTestIsAsync = true; 1 if (self.importScripts) 2 importScripts("../../resources/js-test-pre.js"); 3 4 self.jsTestIsAsync = true; 5 6 if (self.window) 7 description("Basic Behavior test for PerformanceObserver APIs."); 10 8 11 9 // PerformanceObservers that are not actively observing should not fire. … … 27 25 // Observer sees marks while it is registered. 28 26 performance.mark("mark1"); 29 window.observer = new PerformanceObserver(function(list, obs) {30 window.argumentsLength = arguments.length;31 window.list = list;32 window.obs = obs;33 window.thisObject = this;34 27 self.observer = new PerformanceObserver(function(list, obs) { 28 self.argumentsLength = arguments.length; 29 self.list = list; 30 self.obs = obs; 31 self.thisObject = this; 32 35 33 debug("Inside PerformanceObserver callback"); 36 34 shouldBeTrue(`argumentsLength === 2`); … … 68 66 shouldBeTrue(`list.getEntriesByName("mark4")[0] instanceof PerformanceEntry`); 69 67 shouldBeEqualToString(`list.getEntriesByName("mark4")[0].name`, "mark4"); 70 68 71 69 shouldThrow(`list.getEntriesByName()`); 72 70 shouldBeTrue(`list.getEntriesByName("not-real").length === 0`); … … 84 82 shouldBeTrue(`list.getEntriesByName(undefined, "mark").length === 0`); 85 83 86 finishJSTest(); 84 if (self.importScripts) 85 finishJSTest(); 86 else 87 testWorker(); 87 88 }); 88 89 performance.mark("mark2"); … … 90 91 performance.mark("mark3"); 91 92 performance.mark("mark4"); 92 </script>93 <script src="../resources/js-test-post.js"></script>94 </body>95 </html> -
trunk/LayoutTests/performance-api/resources/timeline-api.js
r211593 r211594 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script src="../resources/js-test-pre.js"></script> 5 </head> 6 <body> 7 <script> 8 description("Basic Interface test for performance-timeline APIs."); 1 if (self.importScripts) 2 importScripts("../../resources/js-test-pre.js"); 3 4 if (self.window) 5 description("Basic Interface test for performance-timeline APIs."); 9 6 10 7 debug("PerformanceEntry"); … … 53 50 shouldBeTrue(`performance.getEntriesByName("test", "not-real").length === 0`); 54 51 shouldBeTrue(`performance.getEntriesByName("test", "mark").length === 1`); 55 </script> 56 <script src="../resources/js-test-post.js"></script> 57 </body> 58 </html> 52 53 if (self.importScripts) 54 finishJSTest(); -
trunk/Source/WebCore/CMakeLists.txt
r211406 r211594 588 588 page/EventSource.idl 589 589 page/GlobalCrypto.idl 590 page/GlobalPerformance.idl 590 591 page/History.idl 591 592 page/IntersectionObserver.idl -
trunk/Source/WebCore/ChangeLog
r211592 r211594 1 2017-02-02 Joseph Pecoraro <pecoraro@apple.com> 2 3 Support Performance API (performance.now(), UserTiming) in Workers 4 https://bugs.webkit.org/show_bug.cgi?id=167717 5 6 Reviewed by Ryosuke Niwa. 7 8 Tests: performance-api/performance-mark-name.html 9 performance-api/performance-now-api.html 10 performance-api/performance-now-time-origin-in-worker.html 11 performance-api/user-timing-apis.html 12 13 * CMakeLists.txt: 14 * DerivedSources.make: 15 New files. 16 17 * page/DOMWindow.idl: 18 * page/GlobalPerformance.idl: 19 * workers/WorkerGlobalScope.idl: 20 Add partial interface for performance attribute. 21 22 * page/Performance.idl: 23 * page/PerformanceEntry.idl: 24 * page/PerformanceMark.idl: 25 * page/PerformanceMeasure.idl: 26 * page/PerformanceObserver.idl: 27 * page/PerformanceObserverEntryList.idl: 28 Expose these to Workers. 29 30 * page/Performance.cpp: 31 (WebCore::Performance::Performance): 32 (WebCore::Performance::contextDestroyed): 33 * page/Performance.h: 34 Use the EventQueue variant that works with any ScriptExectionContext. 35 36 * page/PerformanceObserver.cpp: 37 (WebCore::PerformanceObserver::PerformanceObserver): 38 Get the Performance base in a Worker context. 39 40 * page/PerformanceUserTiming.cpp: 41 (WebCore::UserTiming::mark): 42 Only reject legacy special mark names in a Window, not a Worker. 43 44 (WebCore::UserTiming::findExistingMarkStartTime): 45 Simple implementation returns 0 as the start time in Workers. The spec 46 is currently imprecise here, but it does not have the unusual 47 PerformanceTiming behavior in a Window which is part of User Timing 1. 48 49 * workers/Worker.cpp: 50 (WebCore::Worker::create): 51 (WebCore::Worker::notifyFinished): 52 * workers/Worker.h: 53 Record the moment of Worker creation. 54 55 * workers/WorkerGlobalScope.cpp: 56 (WebCore::WorkerGlobalScope::WorkerGlobalScope): 57 (WebCore::WorkerGlobalScope::performance): 58 * workers/WorkerGlobalScope.h: 59 Construct the Performance object with the moment of creation (timeOrigin). 60 61 * workers/DedicatedWorkerGlobalScope.cpp: 62 (WebCore::DedicatedWorkerGlobalScope::create): 63 (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope): 64 * workers/DedicatedWorkerGlobalScope.h: 65 * workers/DedicatedWorkerThread.cpp: 66 (WebCore::DedicatedWorkerThread::DedicatedWorkerThread): 67 (WebCore::DedicatedWorkerThread::createWorkerGlobalScope): 68 * workers/DedicatedWorkerThread.h: 69 * workers/WorkerGlobalScopeProxy.h: 70 * workers/WorkerMessagingProxy.cpp: 71 (WebCore::WorkerMessagingProxy::startWorkerGlobalScope): 72 * workers/WorkerMessagingProxy.h: 73 * workers/WorkerThread.cpp: 74 (WebCore::WorkerThreadStartupData::WorkerThreadStartupData): 75 (WebCore::WorkerThread::WorkerThread): 76 (WebCore::WorkerThread::workerThread): 77 * workers/WorkerThread.h: 78 Pass the moment of creation (timeOrigin) through to WorkerGlobalScope creation. 79 1 80 2017-02-02 Commit Queue <commit-queue@webkit.org> 2 81 -
trunk/Source/WebCore/DerivedSources.make
r211406 r211594 570 570 $(WebCore)/page/EventSource.idl \ 571 571 $(WebCore)/page/GlobalCrypto.idl \ 572 $(WebCore)/page/GlobalPerformance.idl \ 572 573 $(WebCore)/page/History.idl \ 573 574 $(WebCore)/page/IntersectionObserver.idl \ -
trunk/Source/WebCore/page/DOMWindow.idl
r211139 r211594 158 158 [CallWith=ScriptState&CallerWindow, DoNotCheckSecurity, ForwardDeclareInHeader, MayThrowException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []); 159 159 160 [Conditional=WEB_TIMING, Replaceable] readonly attribute Performance performance;161 162 160 long requestAnimationFrame(RequestAnimationFrameCallback callback); 163 161 void cancelAnimationFrame(long id); … … 203 201 DOMWindow implements GlobalCrypto; 204 202 DOMWindow implements GlobalEventHandlers; 203 DOMWindow implements GlobalPerformance; 205 204 DOMWindow implements WindowEventHandlers; 206 205 DOMWindow implements WindowOrWorkerGlobalScope; -
trunk/Source/WebCore/page/GlobalPerformance.idl
r211593 r211594 1 1 /* 2 * Copyright (C) 201 2 IntelInc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // https://w3c.github.io/ user-timing/26 // https://w3c.github.io/hr-time/ 27 27 28 28 [ 29 Conditional=WEB_TIMING, 30 EnabledAtRuntime=UserTiming, 31 ] interface PerformanceMark : PerformanceEntry { 29 NoInterfaceObject, 30 Exposed=(Window,Worker) 31 ] interface GlobalPerformance { 32 [Conditional=WEB_TIMING, Replaceable] readonly attribute Performance performance; 32 33 }; -
trunk/Source/WebCore/page/Performance.cpp
r211527 r211594 55 55 : ContextDestructionObserver(&context) 56 56 , m_timeOrigin(timeOrigin) 57 , m_performanceTimelineTaskQueue(context) 57 58 { 58 59 ASSERT(m_timeOrigin); … … 61 62 Performance::~Performance() 62 63 { 64 } 65 66 void Performance::contextDestroyed() 67 { 68 m_performanceTimelineTaskQueue.close(); 69 70 ContextDestructionObserver::contextDestroyed(); 63 71 } 64 72 -
trunk/Source/WebCore/page/Performance.h
r211527 r211594 91 91 Performance(ScriptExecutionContext&, double timeOrigin); 92 92 93 void contextDestroyed() override; 94 93 95 EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; } 94 96 … … 111 113 std::unique_ptr<UserTiming> m_userTiming; 112 114 113 GenericTaskQueue< Timer> m_performanceTimelineTaskQueue;115 GenericTaskQueue<ScriptExecutionContext> m_performanceTimelineTaskQueue; 114 116 ListHashSet<RefPtr<PerformanceObserver>> m_observers; 115 117 }; -
trunk/Source/WebCore/page/Performance.idl
r211527 r211594 36 36 [ 37 37 Conditional=WEB_TIMING, 38 Exposed=(Window,Worker), 38 39 GenerateIsReachable=ImplScriptExecutionContext, 39 40 ] interface Performance : EventTarget { -
trunk/Source/WebCore/page/PerformanceEntry.idl
r211413 r211594 35 35 [ 36 36 Conditional=WEB_TIMING, 37 CustomToJSObject, 37 38 EnabledAtRuntime=PerformanceTimeline, 38 CustomToJSObject,39 Exposed=(Window,Worker), 39 40 ] interface PerformanceEntry { 40 41 readonly attribute DOMString name; -
trunk/Source/WebCore/page/PerformanceMark.idl
r211133 r211594 29 29 Conditional=WEB_TIMING, 30 30 EnabledAtRuntime=UserTiming, 31 Exposed=(Window,Worker), 31 32 ] interface PerformanceMark : PerformanceEntry { 32 33 }; -
trunk/Source/WebCore/page/PerformanceMeasure.idl
r211133 r211594 29 29 Conditional=WEB_TIMING, 30 30 EnabledAtRuntime=UserTiming, 31 Exposed=(Window,Worker), 31 32 ] interface PerformanceMeasure : PerformanceEntry { 32 33 }; -
trunk/Source/WebCore/page/PerformanceObserver.cpp
r211406 r211594 46 46 m_performance = window->performance(); 47 47 } else if (is<WorkerGlobalScope>(scriptExecutionContext)) { 48 // FIXME: Support Performance Timeline for Workers. 48 auto& workerGlobalScope = downcast<WorkerGlobalScope>(scriptExecutionContext); 49 m_performance = &workerGlobalScope.performance(); 49 50 } else 50 51 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/page/PerformanceObserver.idl
r211406 r211594 31 31 ConstructorCallWith=ScriptExecutionContext, 32 32 EnabledAtRuntime=PerformanceTimeline, 33 Exposed=(Window,Worker), 33 34 ImplementationLacksVTable, 34 35 ] interface PerformanceObserver { -
trunk/Source/WebCore/page/PerformanceObserverEntryList.idl
r211406 r211594 29 29 Conditional=WEB_TIMING, 30 30 EnabledAtRuntime=PerformanceTimeline, 31 Exposed=(Window,Worker), 31 32 ImplementationLacksVTable, 32 33 ] interface PerformanceObserverEntryList { -
trunk/Source/WebCore/page/PerformanceUserTiming.cpp
r211527 r211594 29 29 #if ENABLE(WEB_TIMING) 30 30 31 #include "Document.h" 31 32 #include "ExceptionCode.h" 32 33 #include "Performance.h" 33 34 #include "PerformanceTiming.h" 34 35 #include <array> 36 #include <wtf/MainThread.h> 35 37 #include <wtf/NeverDestroyed.h> 36 38 #include <wtf/dtoa/utils.h> … … 44 46 static NavigationTimingFunction restrictedMarkFunction(const String& markName) 45 47 { 46 // FIXME: Update this list when moving to Navigation Timing Level 2. 48 ASSERT(isMainThread()); 49 47 50 using MapPair = std::pair<ASCIILiteral, NavigationTimingFunction>; 48 51 static const std::array<MapPair, 21> pairs = { { … … 98 101 ExceptionOr<Ref<PerformanceMark>> UserTiming::mark(const String& markName) 99 102 { 100 if (restrictedMarkFunction(markName)) 101 return Exception { SYNTAX_ERR }; 103 if (is<Document>(m_performance.scriptExecutionContext())) { 104 if (restrictedMarkFunction(markName)) 105 return Exception { SYNTAX_ERR }; 106 } 102 107 103 108 auto& performanceEntryList = m_marksMap.ensure(markName, [] { return Vector<RefPtr<PerformanceEntry>>(); }).iterator->value; … … 117 122 return m_marksMap.get(markName).last()->startTime(); 118 123 124 PerformanceTiming* timing = m_performance.timing(); 125 if (!timing) 126 return 0.0; 127 119 128 if (auto function = restrictedMarkFunction(markName)) { 120 if (PerformanceTiming* timing = m_performance.timing()) { 121 double value = static_cast<double>(((*timing).*(function))()); 122 if (!value) 123 return Exception { INVALID_ACCESS_ERR }; 124 return value - timing->navigationStart(); 125 } else { 126 // FIXME: Support UserTiming in Workers. 127 ASSERT_NOT_REACHED(); 128 return Exception { SYNTAX_ERR }; 129 } 129 double value = static_cast<double>(((*timing).*(function))()); 130 if (!value) 131 return Exception { INVALID_ACCESS_ERR }; 132 return value - timing->navigationStart(); 130 133 } 131 134 -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
r210923 r211594 42 42 namespace WebCore { 43 43 44 Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, const String& identifier, const String& userAgent, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)44 Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, const String& identifier, const String& userAgent, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider) 45 45 { 46 auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, identifier, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), connectionProxy, socketProvider));46 auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, identifier, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider)); 47 47 if (!shouldBypassMainWorldContentSecurityPolicy) 48 48 context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders); … … 50 50 } 51 51 52 DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)53 : WorkerGlobalScope(url, identifier, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), connectionProxy, socketProvider)52 DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider) 53 : WorkerGlobalScope(url, identifier, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider) 54 54 { 55 55 } -
trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h
r210923 r211594 49 49 class DedicatedWorkerGlobalScope final : public WorkerGlobalScope { 50 50 public: 51 static Ref<DedicatedWorkerGlobalScope> create(const URL&, const String& identifier, const String& userAgent, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);51 static Ref<DedicatedWorkerGlobalScope> create(const URL&, const String& identifier, const String& userAgent, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*); 52 52 virtual ~DedicatedWorkerGlobalScope(); 53 53 … … 59 59 using Base = WorkerGlobalScope; 60 60 61 DedicatedWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);61 DedicatedWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*); 62 62 63 63 bool isDedicatedWorkerGlobalScope() const final { return true; } -
trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp
r210923 r211594 39 39 namespace WebCore { 40 40 41 DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags)42 : WorkerThread(url, identifier, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, connectionProxy, socketProvider, runtimeFlags)41 DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags) 42 : WorkerThread(url, identifier, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags) 43 43 , m_workerObjectProxy(workerObjectProxy) 44 44 { … … 49 49 } 50 50 51 Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin )51 Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin) 52 52 { 53 return DedicatedWorkerGlobalScope::create(url, identifier, userAgent, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), idbConnectionProxy(), socketProvider());53 return DedicatedWorkerGlobalScope::create(url, identifier, userAgent, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider()); 54 54 } 55 55 -
trunk/Source/WebCore/workers/DedicatedWorkerThread.h
r210923 r211594 50 50 51 51 protected: 52 Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin ) override;52 Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin) override; 53 53 void runEventLoop() override; 54 54 55 55 private: 56 DedicatedWorkerThread(const URL&, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags);56 DedicatedWorkerThread(const URL&, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags); 57 57 58 58 WorkerObjectProxy& m_workerObjectProxy; -
trunk/Source/WebCore/workers/Worker.cpp
r210323 r211594 88 88 worker->setPendingActivity(worker.ptr()); 89 89 90 // https://html.spec.whatwg.org/multipage/workers.html#official-moment-of-creation 91 worker->m_momentOfCreation = monotonicallyIncreasingTime(); 92 90 93 worker->m_scriptLoader = WorkerScriptLoader::create(); 91 94 auto contentSecurityPolicyEnforcement = shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceChildSrcDirective; … … 162 165 else { 163 166 const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders(); 164 m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_ runtimeFlags);167 m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_momentOfCreation, m_runtimeFlags); 165 168 InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); 166 169 } -
trunk/Source/WebCore/workers/Worker.h
r210323 r211594 83 83 WorkerGlobalScopeProxy& m_contextProxy; // The proxy outlives the worker to perform thread shutdown. 84 84 std::optional<ContentSecurityPolicyResponseHeaders> m_contentSecurityPolicyResponseHeaders; 85 double m_momentOfCreation { 0 }; 85 86 bool m_shouldBypassMainWorldContentSecurityPolicy { false }; 86 87 JSC::RuntimeFlags m_runtimeFlags; -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r210923 r211594 34 34 #include "IDBConnectionProxy.h" 35 35 #include "InspectorInstrumentation.h" 36 #include "Performance.h" 36 37 #include "ScheduledAction.h" 37 38 #include "ScriptSourceCode.h" … … 53 54 namespace WebCore { 54 55 55 WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)56 WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, WorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider) 56 57 : m_url(url) 57 58 , m_identifier(identifier) … … 69 70 , m_socketProvider(socketProvider) 70 71 #endif 72 #if ENABLE(WEB_TIMING) 73 , m_performance(Performance::create(*this, timeOrigin)) 74 #endif 71 75 { 72 76 #if !ENABLE(INDEXED_DATABASE) … … 348 352 } 349 353 354 #if ENABLE(WEB_TIMING) 355 356 Performance& WorkerGlobalScope::performance() const 357 { 358 return m_performance; 359 } 360 361 #endif 362 350 363 } // namespace WebCore -
trunk/Source/WebCore/workers/WorkerGlobalScope.h
r210923 r211594 40 40 class ContentSecurityPolicyResponseHeaders; 41 41 class Crypto; 42 class Performance; 42 43 class ScheduledAction; 43 44 class WorkerInspectorController; … … 100 101 Crypto& crypto(); 101 102 103 #if ENABLE(WEB_TIMING) 104 Performance& performance() const; 105 #endif 106 102 107 protected: 103 WorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);108 WorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*); 104 109 105 110 void applyContentSecurityPolicyResponseHeaders(const ContentSecurityPolicyResponseHeaders&); … … 172 177 #endif 173 178 179 #if ENABLE(WEB_TIMING) 180 Ref<Performance> m_performance; 181 #endif 182 174 183 mutable RefPtr<Crypto> m_crypto; 175 184 }; -
trunk/Source/WebCore/workers/WorkerGlobalScope.idl
r210037 r211594 63 63 64 64 WorkerGlobalScope implements GlobalCrypto; 65 WorkerGlobalScope implements GlobalPerformance; 65 66 WorkerGlobalScope implements WindowOrWorkerGlobalScope; -
trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h
r210323 r211594 46 46 static WorkerGlobalScopeProxy& create(Worker&); 47 47 48 virtual void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, JSC::RuntimeFlags) = 0;48 virtual void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, double timeOrigin, JSC::RuntimeFlags) = 0; 49 49 virtual void terminateWorkerGlobalScope() = 0; 50 50 virtual void postMessageToWorkerGlobalScope(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) = 0; -
trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp
r210828 r211594 68 68 } 69 69 70 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, JSC::RuntimeFlags runtimeFlags)70 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, double timeOrigin, JSC::RuntimeFlags runtimeFlags) 71 71 { 72 72 // FIXME: This need to be revisited when we support nested worker one day … … 88 88 #endif 89 89 90 auto thread = DedicatedWorkerThread::create(scriptURL, identifier, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), proxy, socketProvider, runtimeFlags);90 auto thread = DedicatedWorkerThread::create(scriptURL, identifier, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags); 91 91 92 92 workerThreadCreated(thread.get()); -
trunk/Source/WebCore/workers/WorkerMessagingProxy.h
r210323 r211594 45 45 // Implementations of WorkerGlobalScopeProxy. 46 46 // (Only use these functions in the worker object thread.) 47 void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, JSC::RuntimeFlags) final;47 void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, double timeOrigin, JSC::RuntimeFlags) final; 48 48 void terminateWorkerGlobalScope() final; 49 49 void postMessageToWorkerGlobalScope(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) final; -
trunk/Source/WebCore/workers/WorkerThread.cpp
r210923 r211594 73 73 WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED; 74 74 public: 75 WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin );75 WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, double timeOrigin); 76 76 77 77 URL m_scriptURL; … … 83 83 bool m_shouldBypassMainWorldContentSecurityPolicy; 84 84 Ref<SecurityOrigin> m_topOrigin; 85 double m_timeOrigin; 85 86 }; 86 87 87 WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin )88 WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, double timeOrigin) 88 89 : m_scriptURL(scriptURL.isolatedCopy()) 89 90 , m_identifier(identifier.isolatedCopy()) … … 94 95 , m_shouldBypassMainWorldContentSecurityPolicy(shouldBypassMainWorldContentSecurityPolicy) 95 96 , m_topOrigin(topOrigin.isolatedCopy()) 96 { 97 } 98 99 WorkerThread::WorkerThread(const URL& scriptURL, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags) 97 , m_timeOrigin(timeOrigin) 98 { 99 } 100 101 WorkerThread::WorkerThread(const URL& scriptURL, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags) 100 102 : m_threadID(0) 101 103 , m_workerLoaderProxy(workerLoaderProxy) 102 104 , m_workerReportingProxy(workerReportingProxy) 103 105 , m_runtimeFlags(runtimeFlags) 104 , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, identifier, userAgent, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin ))106 , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, identifier, userAgent, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin)) 105 107 #if ENABLE(INDEXED_DATABASE) 106 108 , m_idbConnectionProxy(connectionProxy) … … 162 164 { 163 165 LockHolder lock(m_threadCreationMutex); 164 m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin) );166 m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin); 165 167 166 168 if (m_runLoop.terminated()) { -
trunk/Source/WebCore/workers/WorkerThread.h
r210923 r211594 81 81 82 82 protected: 83 WorkerThread(const URL&, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags);83 WorkerThread(const URL&, const String& identifier, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, double timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags); 84 84 85 85 // Factory method for creating a new worker context for the thread. 86 virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin ) = 0;86 virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, double timeOrigin) = 0; 87 87 88 88 // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
Note: See TracChangeset
for help on using the changeset viewer.