diff --git a/sections/webappapis.include b/sections/webappapis.include index e373ca5498..4cc4e27072 100644 --- a/sections/webappapis.include +++ b/sections/webappapis.include @@ -1979,21 +1979,78 @@ must act as if, for the purposes of event dispatching, the Window object is the parent of the Document object. [[!DOM]] -

Base64 utility methods

+

The WindowOrWorkerGlobalScope mixin

- The atob() and btoa() methods allow authors to transform content to and from - the base64 encoding. + The {{WindowOrWorkerGlobalScope}} mixin is for use of APIs that are to be exposed + on {{Window}} and {{WorkerGlobalScope}} objects. + +

+ Other standards are encouraged to further extend it using partial interface + {{WindowOrWorkerGlobalScope}} { … }; along with an appropriate reference. +

+ +
+    typedef (DOMString or Function) TimerHandler;
 
-  
     [NoInterfaceObject, Exposed=(Window, Worker)]
-    interface WindowBase64 {
+    interface WindowOrWorkerGlobalScope {
+      [Replaceable] readonly attribute USVString origin;
+
+      // Base64 utility methods (WindowBase64)
       DOMString btoa(DOMString btoa);
       DOMString atob(DOMString atob);
+
+      // Timers (WindowTimers)
+      long setTimeout((Function or DOMString) handler, optional long timeout = 0, any... arguments);
+      void clearTimeout(optional long handle = 0);
+      long setInterval((Function or DOMString) handler, optional long timeout = 0, any... arguments);
+      void clearInterval(optional long handle = 0);
+
+      // ImageBitmap, Images (ImageBitmapFactories)
+      Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image);
+      Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh);
     };
-    Window implements WindowBase64;
-    WorkerGlobalScope implements WindowBase64;
+    Window implements WindowOrWorkerGlobalScope;
+    WorkerGlobalScope implements WindowOrWorkerGlobalScope;
   
+
+
origin = self . origin
+
+ Returns the global object's origin, serialized as string. +
+
+ +
+ Developers are strongly encouraged to use self.origin over + location.origin. self.origin returns the origin of the + environment, while location.origin returns URL of the environment. + + Imagine the following script executing in a document on https://example.com: + +
+      var frame = document.createElement("iframe")
+      frame.onload = function() {
+        var frameWin = frame.contentWindow
+        console.log(frameWin.location.origin) // "null"
+        console.log(frameWin.origin) // "https://example.com"
+      }
+      document.body.appendChild(frame)
+    
+ + self.origin is a more reliable security indicator. +
+ + The origin attribute's getter must return this object's relevant + setting object's origin, serialized. + + + +

Base64 utility methods

+ + The atob() and btoa() methods allow authors to transform content to and from + the base64 encoding. +

In these APIs, for mnemonic purposes, the "b" can be considered to stand for "binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the @@ -2538,18 +2595,6 @@ and setInterval() methods allow authors to schedule timer-based callbacks. -

-    [NoInterfaceObject, Exposed=(Window,Worker)]
-    interface WindowTimers {
-      long setTimeout((Function or DOMString) handler, optional long timeout = 0, any... arguments);
-      void clearTimeout(optional long handle = 0);
-      long setInterval((Function or DOMString) handler, optional long timeout = 0, any... arguments);
-      void clearInterval(optional long handle = 0);
-    };
-    Window implements WindowTimers;
-    WorkerGlobalScope implements WindowTimers;
-  
-
handle = window . setTimeout( handler [, timeout [, arguments... ] ] )
@@ -4522,16 +4567,6 @@ ImageBitmap) ImageBitmapSource;
-
-    [NoInterfaceObject, Exposed=(Window, Worker)]
-    interface ImageBitmapFactories {
-      Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image);
-      Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh);
-    };
-    Window implements ImageBitmapFactories;
-    WorkerGlobalScope implements ImageBitmapFactories;
-  
- An ImageBitmap object represents a bitmap image that can be painted to a canvas without undue latency.