Bug 127795 - Implement (most of) URL API
Summary: Implement (most of) URL API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Maciej Stachowiak
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-01-28 14:07 PST by Maciej Stachowiak
Modified: 2014-05-08 08:23 PDT (History)
12 users (show)

See Also:


Attachments
Patch (16.24 KB, patch)
2014-01-28 14:08 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion (791.30 KB, application/zip)
2014-01-28 15:34 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2 (503.04 KB, application/zip)
2014-01-28 15:38 PST, Build Bot
no flags Details
Patch (74.51 KB, patch)
2014-01-30 00:24 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Patch (75.63 KB, patch)
2014-01-30 03:19 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Patch (79.05 KB, patch)
2014-01-30 14:48 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Patch (79.14 KB, patch)
2014-01-30 15:06 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Patch (79.34 KB, patch)
2014-01-30 15:07 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Patch (79.33 KB, patch)
2014-01-30 17:19 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Addressing the latest review feedback; also fix build (79.30 KB, patch)
2014-01-30 17:30 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion (514.56 KB, application/zip)
2014-01-30 18:43 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2 (487.48 KB, application/zip)
2014-01-30 18:48 PST, Build Bot
no flags Details
Now with fewer test failures. (79.68 KB, patch)
2014-01-30 20:23 PST, Maciej Stachowiak
ap: review+
ap: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Stachowiak 2014-01-28 14:07:02 PST
Implement (most of) URL API
Comment 1 Maciej Stachowiak 2014-01-28 14:08:35 PST
Created attachment 222485 [details]
Patch
Comment 2 WebKit Commit Bot 2014-01-28 14:09:47 PST
Attachment 222485 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:10:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Build Bot 2014-01-28 15:34:31 PST
Comment on attachment 222485 [details]
Patch

Attachment 222485 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/6654629710397440

New failing tests:
js/dom/constructor-length.html
fast/dom/constructed-objects-prototypes.html
fast/dom/DOMURL/check-instanceof-domurl-functions.html
Comment 4 Build Bot 2014-01-28 15:34:35 PST
Created attachment 222512 [details]
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-08  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 5 Build Bot 2014-01-28 15:38:09 PST
Comment on attachment 222485 [details]
Patch

Attachment 222485 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6091933696917504

New failing tests:
js/dom/constructor-length.html
fast/dom/constructed-objects-prototypes.html
fast/dom/DOMURL/check-instanceof-domurl-functions.html
Comment 6 Build Bot 2014-01-28 15:38:11 PST
Created attachment 222514 [details]
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-14  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 7 Maciej Stachowiak 2014-01-30 00:24:42 PST
Created attachment 222636 [details]
Patch
Comment 8 Maciej Stachowiak 2014-01-30 00:25:46 PST
Updated patch to fix broken tests, add new tests, and hopefully fix non-Mac builds. Still need to add tests for 'username' and 'password' properties.
Comment 9 Maciej Stachowiak 2014-01-30 03:19:08 PST
Created attachment 222656 [details]
Patch
Comment 10 Maciej Stachowiak 2014-01-30 03:38:18 PST
I think the latest version is ready for review.
Comment 11 Sam Weinig 2014-01-30 09:29:37 PST
Comment on attachment 222656 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=222656&action=review

Notes: 
1) It doesn't seem like you are doing the [EnforceUTF16] step.

> Source/WebCore/html/DOMURL.cpp:96
> +    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(href());
> +    return origin->toString();

I am not sure if this does what we want.  There are many special cases inside both the creation and stringification here which are generally internal.

> Source/WebCore/html/DOMURL.cpp:101
> +    return href().protocol() + ":";

I think this would be a bit more effiicient if you used ':', rather then ":".

> Source/WebCore/html/DOMURL.cpp:151
> +    return value.substring(portStart, portEnd - portStart).toUInt();

What happens if the port is greater than UINT_MAX?

> Source/WebCore/html/DOMURL.cpp:175
> +            // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
> +            // specifically goes against RFC 3986 (p3.2) and
> +            // requires setting the port to "0" if it is set to empty string.
> +            url.setHostAndPort(value.substring(0, separator + 1) + "0");

Should we really do this? Will it ever be right?
Comment 12 Anders Carlsson 2014-01-30 12:52:48 PST
Comment on attachment 222656 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=222656&action=review

> Source/WebCore/html/DOMURL.h:93
> +protected:

Why are these protected and not private?

> Source/WebCore/html/DOMURL.h:95
> +    DOMURL(const String& url, const DOMURL* base, ExceptionCode&);

I think DOMURL* should be a reference here since it can't be null.
Comment 13 Maciej Stachowiak 2014-01-30 13:08:50 PST
(In reply to comment #11)
> (From update of attachment 222656 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=222656&action=review
> 
> Notes: 
> 1) It doesn't seem like you are doing the [EnforceUTF16] step.

I deliberately tried not to make it different from HTMLAnchorElement's existing WebKit behavior, in this patch. Next steps will be to share the code, and then try to match the actual parsing/reassembly requirements of the URL spec.

I'll file a follow-up bug.

> 
> > Source/WebCore/html/DOMURL.cpp:96
> > +    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(href());
> > +    return origin->toString();
> 
> I am not sure if this does what we want.  There are many special cases inside both the creation and stringification here which are generally internal.

It's identical to what HTMLAnchorElement's origin() method does, and it's defined to be the same thing by the URL spec.

If there's specific bugs with this approach that you're aware of I can file follow-up bugs.

> 
> > Source/WebCore/html/DOMURL.cpp:101
> > +    return href().protocol() + ":";
> 
> I think this would be a bit more effiicient if you used ':', rather then ":".

OK, will change (though I'm surprised since all info to make it equally performant should be available at compile-time).

> 
> > Source/WebCore/html/DOMURL.cpp:151
> > +    return value.substring(portStart, portEnd - portStart).toUInt();
> 
> What happens if the port is greater than UINT_MAX?

This matches what HTMLAnchorElement does. I'm not sure what is actually correct, but I'll make both DTRT once I unify the code.

Will file follow-up bug.

> 
> > Source/WebCore/html/DOMURL.cpp:175
> > +            // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
> > +            // specifically goes against RFC 3986 (p3.2) and
> > +            // requires setting the port to "0" if it is set to empty string.
> > +            url.setHostAndPort(value.substring(0, separator + 1) + "0");
> 
> Should we really do this? Will it ever be right?

It matches HTMLAnchorElement. I'm pretty sure it's wrong per the latest spec and doesn't match latest browsers. Will file follow-up bug.
Comment 14 Maciej Stachowiak 2014-01-30 13:11:54 PST
(In reply to comment #12)
> (From update of attachment 222656 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=222656&action=review
> 
> > Source/WebCore/html/DOMURL.h:93
> > +protected:
> 
> Why are these protected and not private?

Blind copying. I'll make them private.

> 
> > Source/WebCore/html/DOMURL.h:95
> > +    DOMURL(const String& url, const DOMURL* base, ExceptionCode&);
> 
> I think DOMURL* should be a reference here since it can't be null.

OK. Although I don't think I can do that at the ::create() level since the bindings call it and don't know to expect a reference. So for correctness the ::create() call would need an ASSERT for the case of possible callers other than the bindings.
Comment 15 Maciej Stachowiak 2014-01-30 14:48:22 PST
Created attachment 222742 [details]
Patch
Comment 17 Maciej Stachowiak 2014-01-30 15:06:33 PST
Created attachment 222745 [details]
Patch
Comment 18 Maciej Stachowiak 2014-01-30 15:07:58 PST
Created attachment 222746 [details]
Patch
Comment 19 Alexey Proskuryakov 2014-01-30 15:50:47 PST
Comment on attachment 222746 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=222746&action=review

This mostly makes sense to me, except for one biggie that makes further review hard - I don't understand base URL handling.

> Source/WebCore/html/DOMURL.cpp:46
> +    return adoptRef(new DOMURL(url, base, ec)); 

It might be slightly better to return nullptr with an exception, not sure.

> Source/WebCore/html/DOMURL.cpp:51
> +PassRefPtr<DOMURL> DOMURL::create(const String& url, const DOMURL* base, ExceptionCode& ec) 
> +{
> +    ASSERT(base);

Can it be passed as reference?

> Source/WebCore/html/DOMURL.cpp:62
> +    : m_baseURL(URL(), base)
> +    , m_url(m_baseURL, url)

Hopefully we have a lot of tests for invalid base URLs to go with this. URL::init code is a bit unconfident about what it's doing:

    // Allow resolutions with a null or empty base URL, but not with any other invalid one.
    // FIXME: Is this a good rule?

> Source/WebCore/html/DOMURL.cpp:98
> +    if (!m_url.isValid()) {
> +        m_url = URL();

I'm not sure if this is what the spec calls for. Shouldn't "input" be made equal to the invalid URL?

> Source/WebCore/html/DOMURL.cpp:209
> +    // Before setting new value:
> +    // Remove all leading U+002F SOLIDUS ("/") characters.

I don't see any text requiring this in the URL spec. Why is this needed here, but not everywhere we use url.setHost()?

> Source/WebCore/html/DOMURL.cpp:293
> +    return AtomicString(String("#" + fragmentIdentifier));

Like elsewhere, adding a character is faster than adding a single character string.

Apparently you can't have both const char* and const char[N] specializations for a template, which is why we lose the size at compile time, and use strlen.

> Source/WebCore/html/DOMURL.h:98
> +    URL m_baseURL;

I'm having huge difficulty understanding what URL standard tries to say about base URL.

Step 4 of constructor algorithm says "Let result's get the base return base". But "get the base" is an algorithm that must be defined by an external spec. How can we change what some unknown algorithm returns?

> Source/WebCore/html/URLUtils.idl:13
> + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY

APPLE COMPUTER
Comment 20 Maciej Stachowiak 2014-01-30 17:04:10 PST
(In reply to comment #19)
> (From update of attachment 222746 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=222746&action=review
> 
> This mostly makes sense to me, except for one biggie that makes further review hard - I don't understand base URL handling.

What's the specific question about it? The basic concept is that if you construct a relative URL, or assign href to a relative value, you resolve against the base. Unlike HTMLAnchorElement, which resolves against the document base, DOMURL defaults to "about:blank" and lets you specify an explicit base.

> 
> > Source/WebCore/html/DOMURL.cpp:46
> > +    return adoptRef(new DOMURL(url, base, ec)); 
> 
> It might be slightly better to return nullptr with an exception, not sure.

The exception is only really important for the JS binding. Not sure it is worth the extra effort to return nullptr but it can be done.

> 
> > Source/WebCore/html/DOMURL.cpp:51
> > +PassRefPtr<DOMURL> DOMURL::create(const String& url, const DOMURL* base, ExceptionCode& ec) 
> > +{
> > +    ASSERT(base);
> 
> Can it be passed as reference?

I don't know of a way to get the bindings generator to pass a reference instead of a pointer (this ::create() function gets called by the generated constructor).

> 
> > Source/WebCore/html/DOMURL.cpp:62
> > +    : m_baseURL(URL(), base)
> > +    , m_url(m_baseURL, url)
> 
> Hopefully we have a lot of tests for invalid base URLs to go with this. URL::init code is a bit unconfident about what it's doing:
> 
>     // Allow resolutions with a null or empty base URL, but not with any other invalid one.
>     // FIXME: Is this a good rule?
> 
> > Source/WebCore/html/DOMURL.cpp:98
> > +    if (!m_url.isValid()) {
> > +        m_url = URL();
> 
> I'm not sure if this is what the spec calls for. Shouldn't "input" be made equal to the invalid URL?

It says "url" should be made null. I was not able to figure out what other effect "input" would have but maybe if I read closer, I'll figure out the intended observable effect.

> 
> > Source/WebCore/html/DOMURL.cpp:209
> > +    // Before setting new value:
> > +    // Remove all leading U+002F SOLIDUS ("/") characters.
> 
> I don't see any text requiring this in the URL spec. Why is this needed here, but not everywhere we use url.setHost()?
> 

This is copied from HTMLAnchorElement. I don't think it's right per the URL spec, but I'd like to fix it after I make the code shared. Will fix follow-up bug. I think what the spec calls for is %-escaping the "/" (effectively).

> > Source/WebCore/html/DOMURL.cpp:293
> > +    return AtomicString(String("#" + fragmentIdentifier));
> 
> Like elsewhere, adding a character is faster than adding a single character string.

Will fix.

> 
> Apparently you can't have both const char* and const char[N] specializations for a template, which is why we lose the size at compile time, and use strlen.
> 
> > Source/WebCore/html/DOMURL.h:98
> > +    URL m_baseURL;
> 
> I'm having huge difficulty understanding what URL standard tries to say about base URL.
> 
> Step 4 of constructor algorithm says "Let result's get the base return base". But "get the base" is an algorithm that must be defined by an external spec. How can we change what some unknown algorithm returns?

URLUtils is a generic interface that is also implemented by other things (e.g. HTMLAnchorElement and Location) which may have their own definition of "get the base". For URL itself, "get the base" is defined to return the base that was specified to the constructor.

> 
> > Source/WebCore/html/URLUtils.idl:13
> > + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
> 
> APPLE COMPUTER

Will fix.
Comment 21 Maciej Stachowiak 2014-01-30 17:10:16 PST
Follow-up bug for the setHostname() issue:
https://bugs.webkit.org/show_bug.cgi?id=127970
Comment 22 Maciej Stachowiak 2014-01-30 17:11:49 PST
Comment on attachment 222746 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=222746&action=review

>>> Source/WebCore/html/DOMURL.cpp:293
>>> +    return AtomicString(String("#" + fragmentIdentifier));
>> 
>> Like elsewhere, adding a character is faster than adding a single character string.
>> 
>> Apparently you can't have both const char* and const char[N] specializations for a template, which is why we lose the size at compile time, and use strlen.
> 
> Will fix.

Turns out the char, String specialization of operator+ doesn't exist, so I can't make this change at the moment.
Comment 23 Maciej Stachowiak 2014-01-30 17:19:40 PST
Created attachment 222764 [details]
Patch
Comment 24 Maciej Stachowiak 2014-01-30 17:30:00 PST
Created attachment 222768 [details]
Addressing the latest review feedback; also fix build
Comment 25 Build Bot 2014-01-30 18:43:32 PST
Comment on attachment 222768 [details]
Addressing the latest review feedback; also fix build

Attachment 222768 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5321528434491392

New failing tests:
fast/dom/DOMURL/set-href-attribute-host.html
fast/dom/DOMURL/set-href-attribute-pathname.html
fast/dom/DOMURL/set-href-attribute-hostname.html
fast/dom/DOMURL/set-href-attribute-hash.html
Comment 26 Build Bot 2014-01-30 18:43:35 PST
Created attachment 222779 [details]
Archive of layout-test-results from webkit-ews-01 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-01  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 27 Build Bot 2014-01-30 18:48:43 PST
Comment on attachment 222768 [details]
Addressing the latest review feedback; also fix build

Attachment 222768 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5256801935163392

New failing tests:
fast/dom/DOMURL/set-href-attribute-host.html
fast/dom/DOMURL/set-href-attribute-pathname.html
fast/dom/DOMURL/set-href-attribute-hostname.html
fast/dom/DOMURL/set-href-attribute-hash.html
Comment 28 Build Bot 2014-01-30 18:48:47 PST
Created attachment 222780 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 29 Maciej Stachowiak 2014-01-30 20:23:03 PST
Created attachment 222788 [details]
Now with fewer test failures.
Comment 30 Alexey Proskuryakov 2014-01-30 22:33:29 PST
Comment on attachment 222788 [details]
Now with fewer test failures.

View in context: https://bugs.webkit.org/attachment.cgi?id=222788&action=review

r=me assuming that you would prefer to fix invalid URL handling in a separate patch.

Between the comments below, my only strong request to address before landing is to fix regression tests, please don't split anything into script-tests/*.js files.

> Source/WebCore/html/DOMURL.cpp:77
> +    : m_baseURL(blankURL())

Did you verify that URL("foobar") doesn't result in "about:foobar"? I couldn't easily find that within regression tests.

> Source/WebCore/html/DOMURL.cpp:108
> +    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(href());

This function, and all other functions that call href(), should first verify that it is a valid URL. The URL standard says: "The origin attribute must run these steps: 1. If url is null, return the empty string."

Besides, not a lot of WebCore code is prepared to handle invalid URLs, certainly not SecurityOrigin.

Please add regression tests for these fixes.

Finally, all calls to href() should just use m_url.

> Source/WebCore/html/DOMURL.cpp:120
> +    URL url = href();
> +    url.setProtocol(value);

Setters are particularly tricky - the URL Standard says that they must be no-op when url is invalid, but WebCore URL class can turn an invalid URL into a valid one. Which may really be a bug in URL, not here.

> Source/WebCore/html/DOMURL.cpp:164
> +    return value.substring(portStart, portEnd - portStart).toUInt();

It may be helpful to have FIXMEs for bugs that you filed, depending on how soon you intend to get to these.

> LayoutTests/fast/dom/DOMURL/get-href-attribute-port.html:1
> +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<!DOCTYPE html>

You can use our make-new-script-test script that creates boilerplate for script tests.

> LayoutTests/fast/dom/DOMURL/get-href-attribute-port.html:7
> +<script src="script-tests/get-href-attribute-port.js"></script>

Please don't add any new tests whose meaningful content is outside the main HTML file, with the only exception being pure js tests meant to be run without even building WebCore.

It is extremely annoying and wasteful to be several steps away from seeing what a given test does.

> LayoutTests/fast/dom/DOMURL/script-tests/TEMPLATE.html:10
> +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> +<html>
> +<head>
> +<script src="../../../resources/js-test-pre.js"></script>
> +</head>
> +<body>
> +<script src="YOUR_JS_FILE_HERE"></script>
> +<script src="../../../resources/js-test-post.js"></script>
> +</body>
> +</html>

Please don't add this file.
Comment 31 Maciej Stachowiak 2014-01-31 01:00:57 PST
(In reply to comment #30)
> (From update of attachment 222788 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=222788&action=review
> 
> r=me assuming that you would prefer to fix invalid URL handling in a separate patch.
> 
> Between the comments below, my only strong request to address before landing is to fix regression tests, please don't split anything into script-tests/*.js files.

All right, I'll recombine the tests.

> 
> > Source/WebCore/html/DOMURL.cpp:77
> > +    : m_baseURL(blankURL())
> 
> Did you verify that URL("foobar") doesn't result in "about:foobar"? I couldn't easily find that within regression tests.

new URL("foobar") throws. I have other tests for invalid attempts to call the constructor throwing but not specifically something that could look like a relative URL with a relative-supporting base. I will add one.

> 
> > Source/WebCore/html/DOMURL.cpp:108
> > +    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(href());
> 
> This function, and all other functions that call href(), should first verify that it is a valid URL. The URL standard says: "The origin attribute must run these steps: 1. If url is null, return the empty string."

HTMLAnchorElement code doesn't do that. I'll file a bug but I'm not entirely sure this is necessary in cases other than origin (I do think the origin property will do the wrong thing as written).

> 
> Besides, not a lot of WebCore code is prepared to handle invalid URLs, certainly not SecurityOrigin.

Really it should be - nothing protects against invalid URLs entering the system, possibly with the exception of a URL that you know you successfully loaded from.

> 
> Please add regression tests for these fixes.
> 
> Finally, all calls to href() should just use m_url.

I'd rather not do that. My plan for sharing code with HTMLAnchorElement is to make a template that takes a class parameter which implements href() and setHref() methods. I think that will be sufficient for implementing all the other methods. At least, it seems to work so far.

> 
> > Source/WebCore/html/DOMURL.cpp:120
> > +    URL url = href();
> > +    url.setProtocol(value);
> 
> Setters are particularly tricky - the URL Standard says that they must be no-op when url is invalid, but WebCore URL class can turn an invalid URL into a valid one. Which may really be a bug in URL, not here.

I'll file a follow-up bug for this.

> 
> > Source/WebCore/html/DOMURL.cpp:164
> > +    return value.substring(portStart, portEnd - portStart).toUInt();
> 
> It may be helpful to have FIXMEs for bugs that you filed, depending on how soon you intend to get to these.

Within the next few days or weeks most likely. Would rather not add FIXMEs since bugzilla already has a record of the problems.

> 
> > LayoutTests/fast/dom/DOMURL/get-href-attribute-port.html:1
> > +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> 
> <!DOCTYPE html>
> 
> You can use our make-new-script-test script that creates boilerplate for script tests.

Most of the tests are copied from HTMLAnchorElement tests, but I'll gladly convert them to the more modern style.

> 
> > LayoutTests/fast/dom/DOMURL/get-href-attribute-port.html:7
> > +<script src="script-tests/get-href-attribute-port.js"></script>
> 
> Please don't add any new tests whose meaningful content is outside the main HTML file, with the only exception being pure js tests meant to be run without even building WebCore.
> 
> It is extremely annoying and wasteful to be several steps away from seeing what a given test does.
> 
> > LayoutTests/fast/dom/DOMURL/script-tests/TEMPLATE.html:10
> > +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
> > +<html>
> > +<head>
> > +<script src="../../../resources/js-test-pre.js"></script>
> > +</head>
> > +<body>
> > +<script src="YOUR_JS_FILE_HERE"></script>
> > +<script src="../../../resources/js-test-post.js"></script>
> > +</body>
> > +</html>
> 
> Please don't add this file.

Also copied from HTMLAnchorElement tests. Will remove.
Comment 32 Alexey Proskuryakov 2014-01-31 08:25:23 PST
Comment on attachment 222788 [details]
Now with fewer test failures.

View in context: https://bugs.webkit.org/attachment.cgi?id=222788&action=review

>>> Source/WebCore/html/DOMURL.cpp:108
>>> +    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(href());
>> 
>> This function, and all other functions that call href(), should first verify that it is a valid URL. The URL standard says: "The origin attribute must run these steps: 1. If url is null, return the empty string."
>> 
>> Besides, not a lot of WebCore code is prepared to handle invalid URLs, certainly not SecurityOrigin.
>> 
>> Please add regression tests for these fixes.
>> 
>> Finally, all calls to href() should just use m_url.
> 
> HTMLAnchorElement code doesn't do that. I'll file a bug but I'm not entirely sure this is necessary in cases other than origin (I do think the origin property will do the wrong thing as written).

Fair enough, other getters do look like they should be OK indeed. Tests for each one would be useful anyway.
Comment 33 Maciej Stachowiak 2014-01-31 14:51:14 PST
I filed the following follow-up bugs:
https://bugs.webkit.org/show_bug.cgi?id=128020
https://bugs.webkit.org/show_bug.cgi?id=128021

I also made all of the requested changes (additional tests, flattening and modernizing test files, etc).
Comment 34 Maciej Stachowiak 2014-01-31 15:01:25 PST
Follow-up bugs are all listed here: https://bugs.webkit.org/show_bug.cgi?id=128023
Comment 35 Maciej Stachowiak 2014-01-31 15:02:01 PST
Committed r163208: <http://trac.webkit.org/changeset/163208>
Comment 36 Alexey Proskuryakov 2014-01-31 16:42:42 PST
Updated a test result in <http://trac.webkit.org/changeset/163220>.
Comment 37 David Kilzer (:ddkilzer) 2014-05-08 08:23:58 PDT
<rdar://problem/15184406>