Skip to content

Commit

Permalink
LibWeb: Change attribute type to USVString where applicable
Browse files Browse the repository at this point in the history
Also mark USVString attributes as containing a URL, where applicable.
  • Loading branch information
tcl3 committed Aug 13, 2024
1 parent d5ef9ab commit df1c985
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Tests/LibWeb/Text/expected/input-image.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../Layout/input/120.png loaded
120.png loaded
file:///i-do-no-exist-i-swear.png failed
15 changes: 15 additions & 0 deletions Tests/LibWeb/Text/expected/usvstring-url-reflection.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
audio.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
embed.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
frame.longDesc final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
frame.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
iframe.longDesc final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
iframe.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
img.longDesc final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
img.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
input.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
link.href final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
script.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
source.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
track.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
video.poster final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
video.src final URL path segment: %EF%BF%BDa%EF%BF%BDb%EF%BF%BD
2 changes: 1 addition & 1 deletion Tests/LibWeb/Text/expected/video-canceled-load.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
wfh
file:///example/file/location/wfh
2 changes: 1 addition & 1 deletion Tests/LibWeb/Text/expected/video-failed-load.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
failed to load: "data:"
failed to load: "file:///i-do-no-exist-i-swear"
failed to load: "https://i-do-no-exist-i-swear.net.uk"
failed to load: "https://i-do-no-exist-i-swear.net.uk/"
3 changes: 2 additions & 1 deletion Tests/LibWeb/Text/input/input-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

return new Promise((resolve, reject) => {
input.addEventListener("load", () => {
resolve(`${input.src} loaded`);
const filename = input.src.split('/').pop();
resolve(`${filename} loaded`);
});
input.addEventListener("error", () => {
resolve(`${input.src} failed`);
Expand Down
29 changes: 29 additions & 0 deletions Tests/LibWeb/Text/input/usvstring-url-reflection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<script src="include.js"></script>
<script>
test(() => {
let elementList = [
{ "audio": "src" },
{ "embed": "src" },
{ "frame": "longDesc" },
{ "frame": "src" },
{ "iframe": "longDesc" },
{ "iframe": "src" },
{ "img": "longDesc" },
{ "img": "src" },
{ "input": "src" },
{ "link": "href" },
{ "script": "src" },
{ "source": "src" },
{ "track": "src" },
{ "video": "poster" },
{ "video": "src" },
];
for (const elementDescriptor of elementList) {
[elementName, propertyName] = Object.entries(elementDescriptor)[0];
const element = document.createElement(elementName);
element[propertyName] = "\udddda\uddddb\udddd";
println(`${elementName}.${propertyName} final URL path segment: ${element[propertyName].split("/").pop()}`);
}
});
</script>
2 changes: 1 addition & 1 deletion Tests/LibWeb/Text/input/video-canceled-load.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script src="include.js"></script>
<script type="text/javascript">
function updateSrc() {
video.src = "wfh";
video.src = "file:///example/file/location/wfh";
}

test(() => {
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface HTMLAnchorElement : HTMLElement {

[CEReactions, Reflect] attribute DOMString target;
[CEReactions, Reflect] attribute DOMString download;
[CEReactions, Reflect] attribute DOMString ping;
[CEReactions, Reflect] attribute USVString ping;
[CEReactions, Reflect] attribute DOMString rel;
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
[CEReactions, Reflect] attribute DOMString hreflang;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface HTMLEmbedElement : HTMLElement {

[HTMLConstructor] constructor();

[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString type;
[CEReactions, Reflect] attribute DOMString width;
[CEReactions, Reflect] attribute DOMString height;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/HTMLFrameElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ interface HTMLFrameElement : HTMLElement {

[CEReactions, Reflect] attribute DOMString name;
[CEReactions, Reflect] attribute DOMString scrolling;
[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect=frameborder] attribute DOMString frameBorder;
[CEReactions, Reflect=longdesc] attribute DOMString longDesc;
[CEReactions, Reflect=longdesc, URL] attribute USVString longDesc;
[CEReactions, Reflect=noresize] attribute boolean noResize;
[FIXME] readonly attribute Document? contentDocument;
[FIXME] readonly attribute WindowProxy? contentWindow;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface HTMLIFrameElement : HTMLElement {

[HTMLConstructor] constructor();

[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString srcdoc;
[CEReactions, Reflect] attribute DOMString name;
[FIXME, SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox;
Expand All @@ -26,7 +26,7 @@ interface HTMLIFrameElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString align;
[CEReactions, Reflect] attribute DOMString scrolling;
[CEReactions, Reflect=frameborder] attribute DOMString frameBorder;
[CEReactions, Reflect=longdesc] attribute USVString longDesc;
[CEReactions, Reflect=longdesc, URL] attribute USVString longDesc;

[CEReactions, LegacyNullToEmptyString, Reflect=marginheight] attribute DOMString marginHeight;
[CEReactions, LegacyNullToEmptyString, Reflect=marginwidth] attribute DOMString marginWidth;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/HTMLImageElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface HTMLImageElement : HTMLElement {
[HTMLConstructor] constructor();

[CEReactions, Reflect] attribute DOMString alt;
[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString srcset;
[CEReactions, Reflect] attribute DOMString sizes;
[CEReactions, Enumerated=CORSSettingsAttribute, Reflect=crossorigin] attribute DOMString? crossOrigin;
Expand All @@ -34,7 +34,7 @@ interface HTMLImageElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString align;
[CEReactions, Reflect] attribute unsigned long hspace;
[CEReactions, Reflect] attribute unsigned long vspace;
[CEReactions, Reflect=longdesc] attribute USVString longDesc;
[CEReactions, Reflect=longdesc, URL] attribute USVString longDesc;

[CEReactions, LegacyNullToEmptyString, Reflect] attribute DOMString border;

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface HTMLInputElement : HTMLElement {
[CEReactions, Reflect=readonly] attribute boolean readOnly;
[CEReactions, Reflect] attribute boolean required;
[CEReactions] attribute unsigned long size;
[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString step;
[CEReactions] attribute DOMString type;
[CEReactions, Reflect=value] attribute DOMString defaultValue;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/HTMLLinkElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface HTMLLinkElement : HTMLElement {

[HTMLConstructor] constructor();

[CEReactions, Reflect] attribute DOMString href;
[CEReactions, Reflect, URL] attribute USVString href;
[CEReactions, Reflect=crossorigin, Enumerated=CORSSettingsAttribute] attribute DOMString? crossOrigin;
[CEReactions, Reflect] attribute DOMString rel;
[CEReactions] attribute DOMString as;
Expand All @@ -19,7 +19,7 @@ interface HTMLLinkElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString hreflang;
[CEReactions, Reflect] attribute DOMString type;
[FIXME, SameObject, PutForwards=value] readonly attribute DOMTokenList sizes;
[CEReactions, Reflect=imagesrcset] attribute DOMString imageSrcset;
[CEReactions, Reflect=imagesrcset] attribute USVString imageSrcset;
[CEReactions, Reflect=imagesizes] attribute DOMString imageSizes;
[CEReactions, Reflect=referrerpolicy, Enumerated=ReferrerPolicy] attribute DOMString referrerPolicy;
[FIXME, SameObject, PutForwards=value] readonly attribute DOMTokenList blocking;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLMediaElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface HTMLMediaElement : HTMLElement {
readonly attribute MediaError? error;

// network state
[Reflect, CEReactions] attribute DOMString src;
[Reflect, CEReactions, URL] attribute USVString src;
[FIXME] attribute MediaProvider? srcObject;
readonly attribute USVString currentSrc;
[Reflect=crossorigin, CEReactions, Enumerated=CORSSettingsAttribute] attribute DOMString? crossOrigin;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLScriptElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface HTMLScriptElement : HTMLElement {

[HTMLConstructor] constructor();

[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString type;
[CEReactions, Reflect=nomodule] attribute boolean noModule;
[CEReactions] attribute boolean async;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/HTMLSourceElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ interface HTMLSourceElement : HTMLElement {

[HTMLConstructor] constructor();

[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString type;
[CEReactions, Reflect] attribute DOMString srcset;
[CEReactions, Reflect] attribute USVString srcset;
[CEReactions, Reflect] attribute DOMString sizes;
[CEReactions, Reflect] attribute DOMString media;
[CEReactions, Reflect] attribute unsigned long width;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLTrackElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface HTMLTrackElement : HTMLElement {
[HTMLConstructor] constructor();

[CEReactions, Enumerated=TrackKindAttribute, Reflect] attribute DOMString kind;
[CEReactions, Reflect] attribute DOMString src;
[CEReactions, Reflect, URL] attribute USVString src;
[CEReactions, Reflect] attribute DOMString srclang;
[CEReactions, Reflect] attribute DOMString label;
[CEReactions, Reflect] attribute boolean default;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLVideoElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface HTMLVideoElement : HTMLMediaElement {
[CEReactions, Reflect] attribute unsigned long height;
readonly attribute unsigned long videoWidth;
readonly attribute unsigned long videoHeight;
[CEReactions, Reflect] attribute USVString poster;
[CEReactions, Reflect, URL] attribute USVString poster;
[CEReactions, Reflect=playsinline] attribute boolean playsInline;

};

0 comments on commit df1c985

Please sign in to comment.