From eb104eb06f1321cc23d9a4f16f6d28ebcbfda2ac Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Sun, 18 Sep 2022 06:30:56 -0700 Subject: [PATCH 1/2] Add support for accessing cross-frame entries. This adds a Document-Policy configuration point for documents, named "share-performance-timeline-with", which acceps a set of origins. If it is non-empty, then ancestor frames whose origins are contained in that set can access the timeline entries of the child frame, either through a PerformanceObserver, or by passing a boolean flag into the various getEntries methods. --- index.html | 96 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index abc069f..daf0137 100644 --- a/index.html +++ b/index.html @@ -48,7 +48,7 @@ "check-punctuation": true, }, doJsonLd: true, - xref: ["hr-time-3", "infra", "html", "dom"], + xref: ["hr-time-3", "infra", "html", "dom", "document-policy"], mdn: "performance-timeline", }; @@ -70,6 +70,8 @@
  • Adds support for {{PerformanceObserver}}.
  • +
  • Adds support for cross-frame timeline sharing. +
  • @@ -263,9 +265,9 @@

    Extensions to the {{Performance}} interface

    performance metric data from the Performance Timeline.

           partial interface Performance {
    -        PerformanceEntryList getEntries ();
    -        PerformanceEntryList getEntriesByType (DOMString type);
    -        PerformanceEntryList getEntriesByName (DOMString name, optional DOMString type);
    +        PerformanceEntryList getEntries (optional boolean includeFrames = false);
    +        PerformanceEntryList getEntriesByType (DOMString type, optional boolean includeFrames = false);
    +        PerformanceEntryList getEntriesByName (DOMString name, optional DOMString type, optional boolean includeFrames = false);
           };
           typedef sequence<PerformanceEntry> PerformanceEntryList;
           
    @@ -276,22 +278,27 @@

    Extensions to the {{Performance}} interface

    getEntries() method

    Returns a PerformanceEntryList object returned by the filter buffer map by name and type algorithm with - name and type set to null.

    + name and type set to null, and + includeFrames set to the method's input + includeFrames parameter.

    getEntriesByType() method

    Returns a PerformanceEntryList object returned by filter buffer map by name and type algorithm with name set to - null, and type set to the method's input - type parameter.

    + null, type set to the method's input + type parameter, and includeFrames set to the + method's input includeFrames parameter.

    getEntriesByName() method

    Returns a PerformanceEntryList object returned by filter buffer map by name and type algorithm with name set to - the method input name parameter, and type set - to null if optional `entryType` is omitted, or set to the - method's input type parameter otherwise.

    + the method's input name parameter, type set to + either null if optional `entryType` is omitted, or the + method's input type parameter otherwise, and + includeFrames set to the method's input + includeFrames parameter.

    @@ -306,6 +313,7 @@

    The PerformanceEntry interface

    readonly attribute DOMString entryType; readonly attribute DOMHighResTimeStamp startTime; readonly attribute DOMHighResTimeStamp duration; + readonly attribute object? source; [Default] object toJSON(); };
    @@ -342,9 +350,16 @@

    The PerformanceEntry interface

    duration concept doesn't apply, a performance metric may choose to return a `duration` of 0. +
    source
    +
    + This attribute MUST return the [=global object=] for the realm in which + this PerformanceEntry was recorded. +

    When toJSON is called, run [[WebIDL]]'s default toJSON steps.

    +

    The toJSON method should not attempt to serialize + the source object reference.

    @@ -403,7 +418,7 @@

    PerformanceObserverCallbackOptions dictionary

    observer is observing when the PerformanceObserver's requires dropped entries is set. -
    +

    observe() method

    The observe() method instructs the user agent to register @@ -557,6 +572,7 @@

    PerformanceObserverInit dictionary

    sequence<DOMString> entryTypes; DOMString type; boolean buffered; + boolean includeFrames; };
    @@ -575,6 +591,11 @@

    PerformanceObserverInit dictionary

    A flag to indicate whether buffered entries should be queued into observer's buffer.
    +
    +
    includeFrames
    +
    A flag to indicate whether entries from child frames should be + observed.
    +
    @@ -658,8 +679,8 @@

    supportedEntryTypes attribute

    Processing

    Queue a PerformanceEntry

    -

    To queue a PerformanceEntry (newEntry), run - these steps:

    +

    To queue a PerformanceEntry (newEntry) + with optional boolean traverse, run these steps:

    1. Let interested observers be an initially empty set of PerformanceObserver objects. @@ -670,6 +691,8 @@

      Queue a PerformanceEntry

    2. Let relevantGlobal be newEntry's relevant global object.
    3. +
    4. Set newEntry's {{PerformanceEntry/source}} to relevantGlobal. +
    5. For each registered performance observer regObs in relevantGlobal's list of registered performance observer objects:
        @@ -713,6 +736,25 @@

        Queue a PerformanceEntry

      1. Queue the PerformanceObserver task with relevantGlobal as input.
      2. +
      3. If traverse is true: +
          +
        1. Let origins be the result of calling + [=get-policy-value=] with `share-performance-timeline-with` + and relevantGlobal's active document.
        2. +
        3. For each browsing context context which is an + ancestor browsing context of relevantGlobal's + browsing context: +
            +
          1. If origins contains the token `*`, or + origins contains context's origin, + Queue a global task on the performance timeline task + source with context's [=browsing context/active + window=] to queue a PerformanceEntry with + newEntry.
          2. +
          +
        4. +
        +
    @@ -801,8 +843,8 @@

    Queue the PerformanceObserver task

    Filter buffer map by name and type

    When asked to run the filter buffer map by name and type - algorithm with optional name and type, run the - following steps:

    + algorithm with optional name, type, and + includeFrames, run the following steps:

    1. Let result be an initially empty list.
    2. @@ -827,8 +869,8 @@

      Filter buffer map by name and type

      continue to the next tuple.
    3. Let entries be the result of running filter - buffer by name and type with buffer, name - and type as inputs. + buffer by name and type with buffer, name, + type and includeFrames as inputs.
    4. For each entry in entries, [=list/append=] entry to result.
    5. @@ -843,14 +885,17 @@

      Filter buffer map by name and type

      Filter buffer by name and type

      When asked to run the filter buffer by name and type - algorithm, with buffer, name, and type - as inputs, run the following steps:

      + algorithm, with buffer, name, type and + includeFrames as inputs, run the following steps:

      1. Let result be an initially empty list.
      2. For each PerformanceEntry entry in buffer, run the following steps:
          +
        1. If includeFrames is not true and this's + relevant global object is not the same as entry's + {{PerformanceEntry/source}}, continue to next entry.
        2. If type is not null and if type is not identical to entry's entryType attribute, continue to next entry. @@ -885,6 +930,19 @@

          Determine if a performance entry buffer is full

    +
    +

    Integrations with other Specifications

    +
    +

    Integration with Document Policy

    +

    This specification defines a [=configuration point=] with the name + share-performance-timeline-with. Its type is + set, and its default value is the empty set.

    +

    Set members must be strings representing origins, or the token `*`, + representing all origins.

    +

    This integration requires a currently-non-specified + "set" type and "string" type in Document Policy.

    +
    +

    Privacy Considerations

    This specification extends the {{Performance}} interface defined by [[HR-TIME-3]] and From 285408684da0002a8dd68ac5adf1dce0dccf1f5e Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Tue, 10 Jan 2023 14:59:25 -0500 Subject: [PATCH 2/2] Remove boolean trap from cross-frame API --- index.html | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 481b4d1..9149cb7 100644 --- a/index.html +++ b/index.html @@ -263,31 +263,50 @@

    Extensions to the {{Performance}} interface

    hosts performance related attributes and methods used to retrieve the performance metric data from the Performance Timeline.

    +      dictionary PerformanceEntryOptions {
    +        DOMString type;
    +        DOMString name;
    +        boolean includeFrames;
    +      };
    +
           partial interface Performance {
    -        PerformanceEntryList getEntries (optional boolean includeFrames = false);
    -        PerformanceEntryList getEntriesByType (DOMString type, optional boolean includeFrames = false);
    -        PerformanceEntryList getEntriesByName (DOMString name, optional DOMString type, optional boolean includeFrames = false);
    +        PerformanceEntryList getEntries (optional PerformanceEntryOptions options = {});
    +        PerformanceEntryList getEntriesByType (DOMString type);
    +        PerformanceEntryList getEntriesByName (DOMString name, optional DOMString type);
           };
           typedef sequence<PerformanceEntry> PerformanceEntryList;
           

    The PerformanceEntryList represents a sequence of PerformanceEntry, providing developers with all the convenience methods found on JavaScript arrays.

    +
    +

    PerformanceEntryOptions dictionary

    +
    +
    type
    +
    A single entry type to be retrieved.
    +
    name
    +
    A string representing the name of entries to be retrieved.
    +
    includeFrames
    +
    A flag to indicate whether entries from child frames should be + retrieved.
    +
    +

    getEntries() method

    Returns a PerformanceEntryList object returned by the filter buffer map by name and type algorithm with - name and type set to null, and - includeFrames set to the method's input - includeFrames parameter.

    + name, type and includeFrames set to the + corresponding members of the method's input options + parameter.

    getEntriesByType() method

    Returns a PerformanceEntryList object returned by filter buffer map by name and type algorithm with name set to null, type set to the method's input - type parameter, and includeFrames set to the - method's input includeFrames parameter.

    + type parameter, and includeFrames set to + false.

    getEntriesByName() method

    @@ -296,8 +315,7 @@

    getEntriesByName() method

    the method's input name parameter, type set to either null if optional `entryType` is omitted, or the method's input type parameter otherwise, and - includeFrames set to the method's input - includeFrames parameter.

    + includeFrames set to false.