From 5ea8e12d62e6039078b1722a752d1e2457967ac9 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 19 May 2016 15:39:51 -0400 Subject: [PATCH 1/5] Use USVString for all URLs This finds all instances where URLs are part of an IDL interface, including where they are reflecting content attributes, and changes the type from DOMString to USVString. This has already been done in some places in a haphazard way, but this commit finishes the process. This allows us to clarify the rules for reflecting USVString attributes, and remove the clause that allows DOMString attributes to reflect URLs. Fixes #1254. Fixes #1266. --- source | 79 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/source b/source index 089e5b737c5..7b1b3674464 100644 --- a/source +++ b/source @@ -7282,23 +7282,26 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d if the content attribute's value is the empty string; and on setting, if the content attribute is not present, it must first be added.

-

If a reflecting IDL attribute is a DOMString or USVString attribute whose content attribute is defined to contain a - URL and is also required to contain a valid non-empty URL potentially - surrounded by spaces, then on getting, the IDL attribute must parse the value of the content attribute relative to the element's node - document and return the resulting URL string if that was successful, or the - content attribute's value otherwise; and on setting, must set the content attribute to the - specified literal value. If the content attribute is absent or if it is present and its value is - the empty string, the IDL attribute must return the empty string.

+

If a reflecting IDL attribute is a USVString attribute + whose content attribute is defined to contain a URL, then on getting, if the + content attribute is absent, the IDL attribute must return the empty string. Otherwise, the IDL + attribute must parse the value of the content attribute relative + to the element's node document and if that is successful, return the resulting + URL string. If parsing fails, then the value of the content attribute must be returned + instead, converted to a USVString. On setting, the content attribute must be set to the + specified new value.

-

If a reflecting IDL attribute is a DOMString or USVString attribute whose content attribute is defined to contain a - URL, then on getting, the IDL attribute must parse - the value of the content attribute relative to the element's node document and return - the resulting URL string if that was successful, or the content attribute's value - otherwise; and on setting, must set the content attribute to the specified literal value. If the - content attribute is absent, the IDL attribute must return the empty string.

+

If a reflecting IDL attribute is a USVString attribute + whose content attribute is defined to contain a URL and is also required to contain a + valid non-empty URL potentially surrounded by spaces, then on getting, if the + content attribute is absent or if it is present and its value is the empty string, the IDL + attribute must return the empty string. Otherwise, the IDL attribute must parse the value of the content attribute relative to the element's node + document and if that is successful, return the resulting URL string. If + parsing fails, then the value of the content attribute must be returned instead, converted to a USVString. + On setting, the content attribute must be set to the specified new value.

If a reflecting IDL attribute is a DOMString attribute whose content attribute is an enumerated attribute, and the IDL attribute is limited to only known @@ -12218,7 +12221,7 @@ gave me some of the songs they wrote. I love sharing my music.</p>

DOM interface:
interface HTMLBaseElement : HTMLElement {
-  [CEReactions] attribute DOMString href;
+  [CEReactions] attribute USVString href;
   [CEReactions] attribute DOMString target;
 };
@@ -17079,7 +17082,7 @@ a friend lost to the
DOM interface:
interface HTMLQuoteElement : HTMLElement {
-  [CEReactions] attribute DOMString cite;
+  [CEReactions] attribute USVString cite;
 };

The HTMLQuoteElement interface is also used by the q element.

@@ -23669,7 +23672,7 @@ interface HTMLHyperlinkElementUtils { HTMLModElement interface:

interface HTMLModElement : HTMLElement {
-  [CEReactions] attribute DOMString cite;
+  [CEReactions] attribute USVString cite;
   [CEReactions] attribute DOMString dateTime;
 };
@@ -24497,7 +24500,7 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
DOM interface:
interface HTMLSourceElement : HTMLElement {
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString type;
   [CEReactions] attribute DOMString srcset;
   [CEReactions] attribute DOMString sizes;
@@ -24750,8 +24753,8 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
 interface HTMLImageElement : HTMLElement {
   [CEReactions] attribute DOMString alt;
-  [CEReactions] attribute DOMString src;
-  [CEReactions] attribute DOMString srcset;
+  [CEReactions] attribute USVString src;
+  [CEReactions] attribute USVString srcset;
   [CEReactions] attribute DOMString sizes;
   [CEReactions] attribute DOMString? crossOrigin;
   [CEReactions] attribute DOMString useMap;
@@ -27663,7 +27666,7 @@ href="?audio">audio</a> test instead.)</p>
DOM interface:
interface HTMLIFrameElement : HTMLElement {
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString srcdoc;
   [CEReactions] attribute DOMString name;
   [CEReactions, SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox;
@@ -28680,7 +28683,7 @@ attribute, set the browsing context name of the element's nes
    
DOM interface:
interface HTMLObjectElement : HTMLElement {
-  [CEReactions] attribute DOMString data;
+  [CEReactions] attribute USVString data;
   [CEReactions] attribute DOMString type;
   [CEReactions] attribute boolean typeMustMatch;
   [CEReactions] attribute DOMString name;
@@ -29574,7 +29577,7 @@ attribute, set the browsing context name of the element's nes
   [CEReactions] attribute unsigned long height;
   readonly attribute unsigned long videoWidth;
   readonly attribute unsigned long videoHeight;
-  [CEReactions] attribute DOMString poster;
+  [CEReactions] attribute USVString poster;
 };
@@ -30088,7 +30091,7 @@ interface HTMLAudioElement : HTMLMediaElement {};
interface HTMLTrackElement : HTMLElement {
   [CEReactions] attribute DOMString kind;
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString srclang;
   [CEReactions] attribute DOMString label;
   [CEReactions] attribute boolean default;
@@ -30336,9 +30339,9 @@ interface HTMLMediaElement : HTMLElement {
   readonly attribute MediaError? error;
 
   // network state
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   attribute MediaProvider? srcObject;
-  readonly attribute DOMString currentSrc;
+  readonly attribute USVString currentSrc;
   [CEReactions] attribute DOMString? crossOrigin;
   const unsigned short NETWORK_EMPTY = 0;
   const unsigned short NETWORK_IDLE = 1;
@@ -40826,7 +40829,7 @@ the cell that corresponds to the values of the two dice.
 
[OverrideBuiltins, LegacyUnenumerableNamedProperties]
 interface HTMLFormElement : HTMLElement {
   [CEReactions] attribute DOMString acceptCharset;
-  [CEReactions] attribute DOMString action;
+  [CEReactions] attribute USVString action;
   [CEReactions] attribute DOMString autocomplete;
   [CEReactions] attribute DOMString enctype;
   [CEReactions] attribute DOMString encoding;
@@ -41433,7 +41436,7 @@ interface HTMLFormElement : HTMLElement {
   [CEReactions] attribute boolean disabled;
   readonly attribute HTMLFormElement? form;
   readonly attribute FileList? files;
-  [CEReactions] attribute DOMString formAction;
+  [CEReactions] attribute USVString formAction;
   [CEReactions] attribute DOMString formEnctype;
   [CEReactions] attribute DOMString formMethod;
   [CEReactions] attribute boolean formNoValidate;
@@ -41453,7 +41456,7 @@ interface HTMLFormElement : HTMLElement {
   [CEReactions] attribute boolean readOnly;
   [CEReactions] attribute boolean required;
   [CEReactions] attribute unsigned long size;
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString step;
   [CEReactions] attribute DOMString type;
   [CEReactions] attribute DOMString defaultValue;
@@ -47966,7 +47969,7 @@ You cannot submit this form when the field is incorrect.
[CEReactions] attribute boolean autofocus; [CEReactions] attribute boolean disabled; readonly attribute HTMLFormElement? form; - [CEReactions] attribute DOMString formAction; + [CEReactions] attribute USVString formAction; [CEReactions] attribute DOMString formEnctype; [CEReactions] attribute DOMString formMethod; [CEReactions] attribute boolean formNoValidate; @@ -55667,7 +55670,7 @@ fur
interface HTMLMenuItemElement : HTMLElement {
   [CEReactions] attribute DOMString type;
   [CEReactions] attribute DOMString label;
-  [CEReactions] attribute DOMString icon;
+  [CEReactions] attribute USVString icon;
   [CEReactions] attribute boolean disabled;
   [CEReactions] attribute boolean checked;
   [CEReactions] attribute DOMString radiogroup;
@@ -57016,7 +57019,7 @@ dictionary RelatedEventInit : EventInit {
    
DOM interface:
interface HTMLScriptElement : HTMLElement {
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString type;
   [CEReactions] attribute DOMString charset;
   [CEReactions] attribute boolean async;
@@ -79891,8 +79894,8 @@ interface History {
   void go(optional long delta = 0);
   void back();
   void forward();
-  void pushState(any data, DOMString title, optional DOMString? url = null);
-  void replaceState(any data, DOMString title, optional DOMString? url = null);
+  void pushState(any data, DOMString title, optional USVString? url = null);
+  void replaceState(any data, DOMString title, optional USVString? url = null);
 };
@@ -91938,7 +91941,7 @@ interface MessageEvent : Event { readonly attribute (WindowProxy or MessagePort)? source; readonly attribute FrozenArray<MessagePort>? ports; - void initMessageEvent(DOMString type, boolean bubbles, boolean cancelable, any data, DOMString origin, DOMString lastEventId, (WindowProxy or MessagePort)? source, sequence<MessagePort>? ports); + void initMessageEvent(DOMString type, boolean bubbles, boolean cancelable, any data, USVString origin, DOMString lastEventId, (WindowProxy or MessagePort)? source, sequence<MessagePort>? ports); }; dictionary MessageEventInit : EventInit { @@ -95315,7 +95318,7 @@ interface WorkerGlobalScope : EventTarget { readonly attribute WorkerGlobalScope self; readonly attribute WorkerLocation location; readonly attribute WorkerNavigator navigator; - void importScripts(DOMString... urls); + void importScripts(USVString... urls); attribute OnErrorEventHandler onerror; attribute EventHandler onlanguagechange; From 43df7b8e10a32ce449840d3671a916f5e0cd1f5e Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 20 May 2016 13:00:47 +0200 Subject: [PATCH 2/5] fixup --- source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source b/source index 7b1b3674464..a893fd1ed9a 100644 --- a/source +++ b/source @@ -24502,7 +24502,7 @@ was an English <a href="/wiki/Music_hall">music hall</a> singer, ...
interface HTMLSourceElement : HTMLElement {
   [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString type;
-  [CEReactions] attribute DOMString srcset;
+  [CEReactions] attribute USVString srcset;
   [CEReactions] attribute DOMString sizes;
   [CEReactions] attribute DOMString media;
 };
@@ -96114,7 +96114,7 @@ interface AbstractWorker {
Dedicated workers and the Worker interface
-
[Constructor(DOMString scriptURL, optional WorkerOptions options), Exposed=(Window,Worker)]
+  
[Constructor(USVString scriptURL, optional WorkerOptions options), Exposed=(Window,Worker)]
 interface Worker : EventTarget {
   void terminate();
 
@@ -96241,7 +96241,7 @@ enum WorkerType { "classic", "module" };
 
   
Shared workers and the SharedWorker interface
-
[Constructor(DOMString scriptURL, optional DOMString name = "", optional WorkerOptions options), Exposed=(Window,Worker)]
+  
[Constructor(USVString scriptURL, optional DOMString name = "", optional WorkerOptions options), Exposed=(Window,Worker)]
 interface SharedWorker : EventTarget {
   readonly attribute MessagePort port;
 };

From 1466649b5d2c8ab79a4f0bb41c115f6f86942984 Mon Sep 17 00:00:00 2001
From: Simon Pieters 
Date: Fri, 20 May 2016 13:37:02 +0200
Subject: [PATCH 3/5] fixup2

---
 source | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/source b/source
index a893fd1ed9a..352bfaae6a4 100644
--- a/source
+++ b/source
@@ -8711,7 +8711,7 @@ partial /*sealed*/ interface Document {
 
   // dynamic markup insertion
   [CEReactions] Document open(optional DOMString type = "text/html", optional DOMString replace = "");
-  WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace = false);
+  WindowProxy open(USVString url, DOMString name, DOMString features, optional boolean replace = false);
   [CEReactions] void close();
   [CEReactions] void write(DOMString... text);
   [CEReactions] void writeln(DOMString... text);
@@ -9395,7 +9395,7 @@ partial /*sealed*/ interface Document {
   

Loading XML documents

partial interface XMLDocument {
-  [CEReactions] boolean load(DOMString url);
+  [CEReactions] boolean load(USVString url);
 };
@@ -24764,7 +24764,7 @@ interface HTMLImageElement : HTMLElement { readonly attribute unsigned long naturalWidth; readonly attribute unsigned long naturalHeight; readonly attribute boolean complete; - readonly attribute DOMString currentSrc; + readonly attribute USVString currentSrc; [CEReactions] attribute DOMString referrerPolicy; };
@@ -58869,7 +58869,7 @@ interface HTMLCanvasElement : HTMLElement { RenderingContext? getContext(DOMString contextId, any... arguments); boolean probablySupportsContext(DOMString contextId, any... arguments); - DOMString toDataURL(optional DOMString type, any... arguments); + USVString toDataURL(optional DOMString type, any... arguments); void toBlob(BlobCallback _callback, optional DOMString type, any... arguments); }; @@ -78006,7 +78006,7 @@ dictionary DragEventInit : MouseEventInit { attribute any opener; [Replaceable] readonly attribute WindowProxy parent; readonly attribute Element? frameElement; - WindowProxy? open(optional DOMString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "", optional boolean replace = false); + WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "", optional boolean replace = false); getter object (DOMString name); // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic // object on the prototype chain. Indeed, this does not make the global object an exotic object. @@ -87017,7 +87017,7 @@ interface NavigatorOnLine {
[Constructor(DOMString type, optional ErrorEventInit eventInitDict), Exposed=(Window,Worker)]
 interface ErrorEvent : Event {
   readonly attribute DOMString message;
-  readonly attribute DOMString filename;
+  readonly attribute USVString filename;
   readonly attribute unsigned long lineno;
   readonly attribute unsigned long colno;
   readonly attribute any error;
@@ -87025,7 +87025,7 @@ interface ErrorEvent : Event {
 
 dictionary ErrorEventInit : EventInit {
   DOMString message = "";
-  DOMString filename = "";
+  USVString filename = "";
   unsigned long lineno = 0;
   unsigned long colno = 0;
   any error = null;
@@ -90192,12 +90192,12 @@ interface NavigatorLanguage {
   
[NoInterfaceObject]
 interface NavigatorContentUtils {
   // content handler registration
-  void registerProtocolHandler(DOMString scheme, DOMString url, DOMString title);
-  void registerContentHandler(DOMString mimeType, DOMString url, DOMString title);
-  DOMString isProtocolHandlerRegistered(DOMString scheme, DOMString url);
-  DOMString isContentHandlerRegistered(DOMString mimeType, DOMString url);
-  void unregisterProtocolHandler(DOMString scheme, DOMString url);
-  void unregisterContentHandler(DOMString mimeType, DOMString url);
+  void registerProtocolHandler(DOMString scheme, USVString url, DOMString title);
+  void registerContentHandler(DOMString mimeType, USVString url, DOMString title);
+  DOMString isProtocolHandlerRegistered(DOMString scheme, USVString url);
+  DOMString isContentHandlerRegistered(DOMString mimeType, USVString url);
+  void unregisterProtocolHandler(DOMString scheme, USVString url);
+  void unregisterContentHandler(DOMString mimeType, USVString url);
 };

The CEReactions] attribute DOMString alt; [CEReactions] attribute DOMString archive; [CEReactions] attribute DOMString code; - [CEReactions] attribute DOMString codeBase; + [CEReactions] attribute USVString codeBase; [CEReactions] attribute DOMString height; [CEReactions] attribute unsigned long hspace; [CEReactions] attribute DOMString name; - [CEReactions] attribute DOMString _object; // the underscore is not part of the identifier + [CEReactions] attribute USVString _object; // the underscore is not part of the identifier [CEReactions] attribute unsigned long vspace; [CEReactions] attribute DOMString width; };

@@ -111797,9 +111797,9 @@ if (s = prompt('What is your name?')) {
interface HTMLFrameElement : HTMLElement {
   [CEReactions] attribute DOMString name;
   [CEReactions] attribute DOMString scrolling;
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString frameBorder;
-  [CEReactions] attribute DOMString longDesc;
+  [CEReactions] attribute USVString longDesc;
   [CEReactions] attribute boolean noResize;
   readonly attribute Document? contentDocument;
   readonly attribute WindowProxy? contentWindow;
@@ -112077,7 +112077,7 @@ if (s = prompt('What is your name?')) {
   [CEReactions] attribute DOMString align;
   [CEReactions] attribute DOMString scrolling;
   [CEReactions] attribute DOMString frameBorder;
-  [CEReactions] attribute DOMString longDesc;
+  [CEReactions] attribute USVString longDesc;
 
   [CEReactions, TreatNullAs=EmptyString] attribute DOMString marginHeight;
   [CEReactions, TreatNullAs=EmptyString] attribute DOMString marginWidth;
@@ -112108,11 +112108,11 @@ if (s = prompt('What is your name?')) {
 
   
partial interface HTMLImageElement {
   [CEReactions] attribute DOMString name;
-  [CEReactions] attribute DOMString lowsrc;
+  [CEReactions] attribute USVString lowsrc;
   [CEReactions] attribute DOMString align;
   [CEReactions] attribute unsigned long hspace;
   [CEReactions] attribute unsigned long vspace;
-  [CEReactions] attribute DOMString longDesc;
+  [CEReactions] attribute USVString longDesc;
 
   [CEReactions, TreatNullAs=EmptyString] attribute DOMString border;
 };
From 35f71984d5833b609ee0c1ed46d824d980be0e89 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Fri, 20 May 2016 14:38:11 +0200 Subject: [PATCH 4/5] fixup3 (window.postMessage) --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 352bfaae6a4..416d6d8f814 100644 --- a/source +++ b/source @@ -78026,7 +78026,7 @@ dictionary DragEventInit : MouseEventInit { unsigned long requestAnimationFrame(FrameRequestCallback callback); void cancelAnimationFrame(unsigned long handle); - void postMessage(any message, DOMString targetOrigin, optional sequence<object> transfer = []); + void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []); }; Window implements GlobalEventHandlers; Window implements WindowEventHandlers; From c24c4caaf872c8bfab50d13ef306da87cc381ea4 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Fri, 20 May 2016 14:54:01 +0200 Subject: [PATCH 5/5] fixup4 (link href, embed src) --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 416d6d8f814..579386ae04a 100644 --- a/source +++ b/source @@ -12390,7 +12390,7 @@ gave me some of the songs they wrote. I love sharing my music.</p>
DOM interface:
interface HTMLLinkElement : HTMLElement {
-  [CEReactions] attribute DOMString href;
+  [CEReactions] attribute USVString href;
   [CEReactions] attribute DOMString? crossOrigin;
   [CEReactions] attribute DOMString rel;
   [CEReactions, SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
@@ -28296,7 +28296,7 @@ href="?audio">audio</a> test instead.)</p>
DOM interface:
interface HTMLEmbedElement : HTMLElement {
-  [CEReactions] attribute DOMString src;
+  [CEReactions] attribute USVString src;
   [CEReactions] attribute DOMString type;
   [CEReactions] attribute DOMString width;
   [CEReactions] attribute DOMString height;