From 953c45d1dd971d4bf143b414617ffd750b82092b Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 11 Jan 2024 18:25:17 +0000 Subject: [PATCH 1/2] LoAF: add remaining script properties - window is a weak reference to the script's window - windowAttribution holds a logical relationship between the script's window and the entry's window Unlike `window`, it's not a weak reference. - pauseDuration accumulates duration of pauses (sync XHR, alert) during a script. - forcedStyleAndLayoutDuration is implementation-specific for the time-being. --- index.bs | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 19a1a1e..dce6337 100644 --- a/index.bs +++ b/index.bs @@ -62,6 +62,8 @@ urlPrefix: https://dom.spec.whatwg.org/; spec: DOM; urlPrefix: https://webidl.spec.whatwg.org/; spec: WEBIDL; type: dfn; text: identifier; url: #dfn-identifier; type: dfn; text: attribute; url: #dfn-attribute; +urlPrefix: https://tc39.es/ecma262/multipage/managing-memory.html + type: dfn; text: weakrefderef; url: #sec-weakrefderef; A {{PerformanceScriptTiming}} has an associated [=script timing info=] timing info. +A {{PerformanceScriptTiming}} has an associated {{ScriptWindowAttribution}} window attribution. + The {{PerformanceScriptTiming/entryType}} attribute's getter step is to return "script". The {{PerformanceScriptTiming/type}} attribute's getter step is to return [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/type=]. @@ -438,6 +459,12 @@ The {{PerformanceScriptTiming/duration}} attribute's getter step is to return th The {{PerformanceScriptTiming/executionStart}} attribute's getter step is to return 0 if [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/execution start time=] is 0; Otherwise the [=relative high resolution time=] given [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/execution start time=] and [=this=]'s [=relevant global object=]. +The {{PerformanceScriptTiming/forcedStyleAndLayoutDuration}} attribute's getter step is to return an [=implementation-defined=] value that represents time spent performing style and layout synchronously, e.g. by calling {{Window/getComputedStyle()}} or {{Element/getBoundingClientRect()}}. + + Issue: Find a way to make this interoperable/normative. Perhaps mark those functions in WebIDL as requiring synchronous style/layout? + +The {{PerformanceScriptTiming/pauseDuration}} attribute's getter step is to return [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/pause duration=]. + The {{PerformanceScriptTiming/sourceLocation}} attribute's getter steps are: 1. If [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/source url=] is the empty string, return the empty string. 1. Let |serializedSourceLocation| be [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/source url=]. @@ -447,6 +474,12 @@ The {{PerformanceScriptTiming/sourceLocation}} attribute's getter steps are: set |serializedSourceLocation| to the [=concatenate|concatenation=] of «|serializedSourceLocation|, ":", [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/source character position=] ». 1. Return |serializedSourceLocation|. +The {{PerformanceScriptTiming/window}} attribute's getter steps are: + 1. Let |window| be the result of calling [=weakrefderef|deref=] on [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/window=]. + 1. If |window| is undefined, then return null; Otherwise return |window|. + +The {{PerformanceScriptTiming/windowAttribution}} attribute's getter step is to return [=this=]'s [=PerformanceScriptTiming/window attribution=]. + Processing model {#sec-processing-model} ======================================== @@ -599,6 +632,9 @@ It has the following [=struct/items=]: : execution start time :: An unsafe {{DOMHighResTimeStamp}}, initially 0. + : pause duration + :: A {{DOMHighResTimeStamp}} representing a number of milliseconds, initially 0. + : invoker name : source url : source function name @@ -609,6 +645,9 @@ It has the following [=struct/items=]: : source character position :: A number, initially -1. + + : window + :: A {{WeakRef}} to a {{Window}}. A {{Document}} has a null or [=frame timing info=] current frame timing info, initially null. @@ -799,6 +838,7 @@ Report Long Animation Frames {#loaf-processing-model} whose [=script timing info/start time=] is the [=unsafe shared current time=], and whose [=script timing info/type=] is |type|. 1. Run |steps| given |scriptTimingInfo| and |frameTimingInfo|. + 1. Set |scriptTimingInfo|'s [=script timing info/window=] to |settings|. 1. Set |frameTimingInfo|'s [=frame timing info/pending script=] to |scriptTimingInfo|. @@ -829,6 +869,21 @@ Report Long Animation Frames {#loaf-processing-model} 1. The user agent may set |scriptTimingInfo|'s [=script timing info/source character position=] to the character position where |callback| was defined. +
+ To report pause duration given a [=duration=] |duration|: + 1. Let |script| be the [=running script=]. + 1. Let |settings| be |script|'s [=script/settings object=]. + 1. If |settings| is not a {{Window}}, then return. + 1. Let |document| be |settings|'s {{Window/document}}. + 1. If |document| is not [=fully active=] or {{Document/hidden}}, then return. + 1. Let |frameTimingInfo| be |document|'s [=relevant frame timing info=]. + 1. If |frameTimingInfo| is null, then return. + 1. If |frameTimingInfo|'s [=frame timing info/pending script=] is null, then return. + 1. Increment |frameTimingInfo|'s [=frame timing info/pending script=]'s [=script timing info=/pause duration=] by the milliseconds value of |duration|. + + +
+ Additions to existing standards {#other-standards} ================================================== @@ -928,7 +983,13 @@ Monkey-patches to the HTML standard {#html-monkey-patches}
Append the following step to perform a microtask checkpoint: [=Flush script entry point=]. +
+ +
+ Add the following steps to pause: + Prepend the following step: Let |timeBeforePause| be the [=monotonic clock/unsafe current time=]. + Append the following step: [=Report pause duration=] given the [=duration=] between |timeBeforePause| and the [=monotonic clock/unsafe current time=].
Security & privacy considerations {#priv-sec} From 2e4f83bded508a19239546a5b9f3b4170665d2dc Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 11 Jan 2024 20:19:53 +0000 Subject: [PATCH 2/2] nits --- index.bs | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/index.bs b/index.bs index dce6337..566a6d4 100644 --- a/index.bs +++ b/index.bs @@ -363,18 +363,30 @@ The {{PerformanceLongAnimationFrameTiming/blockingDuration}} attribute's getter The {{PerformanceLongAnimationFrameTiming/scripts}} attribute's getter steps are: 1. Let |scripts| be a [=/list=] « ». + 1. Let |entryWindow| be |this|'s [=relevant global object=]. 1. [=list/For each=] |scriptInfo| in [=this=]'s [=frame timing info=]'s [=frame timing info/scripts=]: + 1. Let |scriptWindow| be |scriptInfo|'s [=script timing info/window=]. 1. Let |scriptEntry| be a new {{PerformanceScriptTiming}} in [=this=]'s [=relevant realm=], - whose [=PerformanceScriptTiming/timing info=] is |scriptInfo| and whose [=PerformanceScriptTiming/window attribution=] is the result of the following steps: - - 1. Let |scriptWindow| be |scriptInfo|'s [=script timing info/window=]. - 1. Let |entryWindow| be |this|'s [=relevant global object=]. - 1. If |scriptWindow| is undefined, then return {{ScriptWindowAttribution/other}}. - 1. If |scriptWindow| is |entryWindow|, then return {{ScriptWindowAttribution/self}}. - 1. If |entryWindow|'s associated {{Document}}'s [=node navigable=]'s [=ancestor navigables=] [=list/contains=] |scriptWindow|'s associated {{Document}}'s [=node navigable=], then return {{ScriptWindowAttribution/ancestor}}. - 1. If |scriptWindow|'s associated {{Document}}'s [=node navigable=]'s [=ancestor navigables=] [=list/contains=] |entryWindow|'s associated {{Document}}'s [=node navigable=], then return {{ScriptWindowAttribution/descendant}}. - 1. If |entryWindow|'s associated {{Document}}'s [=node navigable=]'s [=navigable/top-level traversable=] is |scriptWindow|'s associated {{Document}}'s [=node navigable=]'s [=navigable/top-level traversable=], then return {{ScriptWindowAttribution/same-page}}. - 1. Return {{ScriptWindowAttribution/other}}. + whose [=PerformanceScriptTiming/timing info=] is |scriptInfo| and whose [=PerformanceScriptTiming/window attribution=] is the value corresponding to the first matching statement: + + : |scriptWindow| is undefined + :: {{ScriptWindowAttribution/other}} + + : |scriptWindow| is |entryWindow| + :: {{ScriptWindowAttribution/self}} + + : |entryWindow|'s associated {{Document}}'s [=node navigable=]'s [=ancestor navigables=] [=list/contains=] |scriptWindow|'s associated {{Document}}'s [=node navigable=] + :: {{ScriptWindowAttribution/ancestor}} + + : |scriptWindow|'s associated {{Document}}'s [=node navigable=]'s [=ancestor navigables=] [=list/contains=] |entryWindow|'s associated {{Document}}'s [=node navigable=] + :: {{ScriptWindowAttribution/descendant}} + + : |entryWindow|'s associated {{Document}}'s [=node navigable=]'s [=navigable/top-level traversable=] is |scriptWindow|'s associated {{Document}}'s [=node navigable=]'s [=navigable/top-level traversable=] + :: {{ScriptWindowAttribution/same-page}} + + : Otherwise + :: {{ScriptWindowAttribution/other}}. + 1. [=list/Append=] |scriptEntry| to |scripts|. 1. Return |scripts|. @@ -461,7 +473,7 @@ The {{PerformanceScriptTiming/executionStart}} attribute's getter step is to ret The {{PerformanceScriptTiming/forcedStyleAndLayoutDuration}} attribute's getter step is to return an [=implementation-defined=] value that represents time spent performing style and layout synchronously, e.g. by calling {{Window/getComputedStyle()}} or {{Element/getBoundingClientRect()}}. - Issue: Find a way to make this interoperable/normative. Perhaps mark those functions in WebIDL as requiring synchronous style/layout? + Issue: Find a way to make this interoperable/normative. Perhaps mark those functions in WebIDL as requiring synchronous style/layout? Also move to [=PerformanceScriptTiming/timing info=] once that's resolved. The {{PerformanceScriptTiming/pauseDuration}} attribute's getter step is to return [=this=]'s [=PerformanceScriptTiming/timing info=]'s [=script timing info/pause duration=]. @@ -879,9 +891,7 @@ Report Long Animation Frames {#loaf-processing-model} 1. Let |frameTimingInfo| be |document|'s [=relevant frame timing info=]. 1. If |frameTimingInfo| is null, then return. 1. If |frameTimingInfo|'s [=frame timing info/pending script=] is null, then return. - 1. Increment |frameTimingInfo|'s [=frame timing info/pending script=]'s [=script timing info=/pause duration=] by the milliseconds value of |duration|. - - + 1. Increment |frameTimingInfo|'s [=frame timing info/pending script=]'s [=script timing info/pause duration=] by the milliseconds value of |duration|. Additions to existing standards {#other-standards} @@ -988,8 +998,9 @@ Monkey-patches to the HTML standard {#html-monkey-patches}
Add the following steps to pause: - Prepend the following step: Let |timeBeforePause| be the [=monotonic clock/unsafe current time=]. - Append the following step: [=Report pause duration=] given the [=duration=] between |timeBeforePause| and the [=monotonic clock/unsafe current time=]. + Prepend the following step: Let |timeBeforePause| be the [=monotonic clock/unsafe current time=]. + + Append the following step: [=Report pause duration=] given the [=duration=] between |timeBeforePause| and the [=monotonic clock/unsafe current time=].
Security & privacy considerations {#priv-sec}