From 898e0c1fc583c228596d12d64d2ad300b5fcd248 Mon Sep 17 00:00:00 2001 From: Matt Wolenetz Date: Wed, 21 Sep 2022 12:28:59 -0700 Subject: [PATCH] Restrict handle getter visibility to dedicated worker (#317) Removes the MediaSource handle attribute visibility from the main Window context, leaving it visible only in dedicated worker contexts. Also removes the conditional throwing of NotSupportedError exceptions on getting this attribute's value if the implementation doesn't support that. Overall, this change is to undo the backwards incompatibility issue found when older versions of MSE web app libraries enumerated main thread MediaSource attribute values, hitting exception in the Chromium feature implementation through milestone 107. This change replaces that with simpler and safer visibility restriction of this getter to just the context where it must be supported if the implementation supports MSE-in-Workers. Note, this change replaces the alternative fix discussed in w3c/media-source PR #316. Reference feature tracking spec issue for MSE-in-Workers w3c/media-source issue #175. --- media-source-respec.html | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/media-source-respec.html b/media-source-respec.html index 88e2daa..2bd0907 100644 --- a/media-source-respec.html +++ b/media-source-respec.html @@ -322,7 +322,10 @@

MediaSource Object

[Exposed=(Window,DedicatedWorker)]
 interface MediaSource : EventTarget {
     constructor();
-    [SameObject] readonly attribute MediaSourceHandle   handle;
+
+    [ SameObject, Exposed=DedicatedWorker ]
+    readonly              attribute MediaSourceHandle   handle;
+
     readonly              attribute SourceBufferList    sourceBuffers;
     readonly              attribute SourceBufferList    activeSourceBuffers;
     readonly              attribute ReadyState          readyState;
@@ -344,22 +347,22 @@ 

Attributes

handle of type MediaSourceHandle, [SameObject] readonly
-

Contains a handle useful for attachment to an {{HTMLMediaElement}} via {{HTMLMediaElement/srcObject}}. - The handle remains the same object for this {{MediaSource}} object across accesses of this attribute, but it - is distinct for each {{MediaSource}} object.

+

Contains a handle useful for attachment of a dedicated worker {{MediaSource}} object to an + {{HTMLMediaElement}} via {{HTMLMediaElement/srcObject}}. The handle remains the same object for this + {{MediaSource}} object across accesses of this attribute, but it is distinct for each {{MediaSource}} + object.

+ +

This specification may eventually enable visibility of this attribute on {{MediaSource}} + objects on the main Window context. If so, specification care will be necessary to prevent potential backwards + incompatible changes, such as could happen if exceptions were thrown on accesses to this attribute.

+

On getting, run the following steps:

    -
  1. If the implementation does not support creating a handle for this {{MediaSource}}, then throw a - {{NotSupportedError}} exception and abort these steps. -

    Implementations MAY choose to only allow handle creation for {{MediaSource}} objects in a - {{DedicatedWorkerGlobalScope}}, as a minimum requirement for enabling attachment of such a {{MediaSource}} - object to an {{HTMLMediaElement}}.

  2. If the handle for this {{MediaSource}} object has not yet been created, then run the following steps:
      -
    1. Let |created handle:MediaSourceHandle| be the result of creating a new - {{MediaSourceHandle}} object and associated resources, linked internally to this - {{MediaSource}}.
    2. +
    3. Let |created handle:MediaSourceHandle| be the result of creating a new {{MediaSourceHandle}} object + and associated resources, linked internally to this {{MediaSource}}.
    4. Update the attribute to be |created handle|.
  3. Return the {{MediaSourceHandle}} object that is this attribute's value.