Stream

 

I hate the current experience of creating and managing SSL certs with all my soul. Enough to put people off using encryption for life
‐ Also on:
Mentions:
Steven Livingstone
Jeremy Keith
@glennjones YES!! I wish that security advocates would realise that the problem isn’t lack of will; the problem is good ol’ fashioned pain.
Glenn Jones
@adactio It’s a classic definition of a UX issue, a process that helps me fail at every point and leaves you feeling stupid and disempowered
Glenn Jones
@weblivz I so hope @letsencrypt and the next generation certificate authorities fix this problem


Performance testing microformats parser as it walks through the DOM. Never realised how fast Safari is, shame its #thenewIE : )
‐ Also on:

Taking a look at the profile and performance areas of the browsers, liking Firefox's performance tab, anyone known of a good post about it?
‐ Also on:




In reply to this conservation:
Tobie Langel
@glennjones that's a tough one indeed. What else could IE do not to cause that issue? /cc @adrianba
Glenn Jones
Find it a little sad some of the browser APIs are introduced in such an incomplete state the only way to use them is in try/catch blocks
Tobie Langel
@glennjones are these implementation issues or spec ones?
Tobie Langel
@adrianba I don't know. Would not shipping a partial implementation help? @glennjones
Ade Bateman
@tobie @glennjones We shipped a complete implementation of what was in the File API spec at the time (which only defined static members).
Ade Bateman
@tobie @glennjones IE10+ only supported the static methods on URL so there is no constructor. At the time what else could it do but throw?
Glenn Jones
@tobie @adrianba I don't known the history, but it does look like the URL object should not have been extended in this way, not a IE issue!
Ade Bateman
@glennjones @tobie It's complicated because I think things were proceeding in parallel. I actually don't think there is a problem here.
Tobie Langel
@adrianba I'm not blaming IE, btw. We just don't have a good story for these issues. @glennjones
Glenn Jones
@tobie just looking at URL and URLUtils the constructor of URL takes 2 arguments to resolve absolute URL, but the early IE version blows up
Tobie Langel
@adrianba agreed. Still, that makes it painful for devs. There must be a better way. @glennjones
Tobie Langel
@adrianba sounds like the @urlstandard should have taken that in account then. @glennjones
@tobie @adrianba @w3ctag its an issue with API design, developer expectations and documentation. Wrote post: http://bit.ly/1RkmWqP
‐ Also on:
Mentions:
Ade Bateman
@glennjones BTW, I expect IE11 to be around for a long time, but not IE10.
Robin Berjon
@glennjones Not wonderful, but you might be able to test window.URL.prototype.constructor.length or some such. @tobie @adrianba @w3ctag
Tobie Langel
@robinberjon I'm sure you meant window.URL.prototype.constructor.prototype.constructor.length. #bettersafethansorry @glennjones @adrianba

The problem with window.URL

I was working on a library where I needed to resolve a relative URL using a base URL with JavaScript in the browser. After googling I found the relatively new window.URL API documented on MDN. It allows you to create a URL object that returns a resolved URL, which was great, just what I needed!


var url = new URL('/test.htm', 'http://example.com');
console.log( url.toString() );  
// output is:  http://example.com/test.htm

As with all new API’s I don’t expect all the browsers to support them straight away, but that’s OK I can test for the existence of APIs such as window.URL and use a fallback or polyfill. The code should look something like this.


if(window.URL){
	var url = new URL('/test.htm', 'http://example.com');
	console.log( url.toString() );
else{
	// do something else – fallback or polyfill
}

In this case it does not work because the URL API is actually two overlapping specifications and designed in such a way to allow for one to break the other if they are not implemented together. This is because they both lay claim to the window.URL object. The two specifications are:

The problem

The IE team have implemented just the File API specification, which is not wrong in itself, but if you try use the URL object in IE10 as specified in the URL API specification it throws an error and stops the code execution. Testing for window.URL will not help you as it does exist in IE10 and IE11.

I don’t think IE throwing the error is the issue. Its more of a case of how did the wider web community design APIs that end up clashing?

The workaround

You need to write something like this:


// test URL object for parse support
function hasURLParseSupport (){
	try{
		var url = new URL('/test.htm', 'http://example.com');
		return true;
	}catch(e){
		return false;
	}
}

if(hasParseURLSupport()){
	var url = new URL('/test.htm', 'http://example.com');
	console.log( url.toString() );
}else{
	// do something else
}  

Not meeting expectation’s

Having done a bit of UX design in my time I would class this issue of one of not meeting developers expectations. At least to me using a try/catch block is not how I expect to have to deal with the implementation of new APIs. This should have been resolved at the API design stage before they became public in the browsers.

Wasting time

It took me quite a bit of research to work out what the issue was (2-3 hours) and come up with a small workaround I could trust. Mainly because I had to start reading the specifications and running browser tests.

Going forward

  • As IE10 will be with us for many years the only practical way to use the URL object will be to use more complex tests like the hasURLParseSupport above.
  • This issue should be recognized in the two specifications that lay claim over the URL object.
  • The places that provide documentation of the APIs like MDN should discuss the issue and provide code examples of workarounds.
  • The W3Ctag should review overlapping specifications in fine detail to provide advice on implementation at this level.

I may have got the above wrong

I would just like to point out I am just a web developer and not part of the specifications community that created URL APIs. It’s possible that I may have missed some element of the specifications that deals with this issue. I do not know about the whole history of the URL object and all the discussions of its design. Please let me know if any of the above is incorrect of or can be added too and I will change the post.

Links

  • url javascript api

In reply to this conservation:
Glenn Jones
Find it a little sad some of the browser APIs are introduced in such an incomplete state the only way to use them is in try/catch blocks
Tobie Langel
@glennjones are these implementation issues or spec ones?
Glenn Jones
@tobie just looking at URL and URLUtils the constructor of URL takes 2 arguments to resolve absolute URL, but the early IE version blows up
Tobie Langel
@glennjones that's a tough one indeed. What else could IE do not to cause that issue? /cc @adrianba
Ade Bateman
@tobie @glennjones IE10+ only supported the static methods on URL so there is no constructor. At the time what else could it do but throw?
Tobie Langel
@adrianba agreed. Still, that makes it painful for devs. There must be a better way. @glennjones
Tobie Langel
@adrianba I don't know. Would not shipping a partial implementation help? @glennjones
Ade Bateman
@tobie @glennjones We shipped a complete implementation of what was in the File API spec at the time (which only defined static members).
Tobie Langel
@adrianba sounds like the @urlstandard should have taken that in account then. @glennjones
@tobie @adrianba I don't known the history, but it does look like the URL object should not have been extended in this way, not a IE issue!
‐ Also on:
Mentions:
Ade Bateman
@glennjones @tobie It's complicated because I think things were proceeding in parallel. I actually don't think there is a problem here.
Tobie Langel
@adrianba I'm not blaming IE, btw. We just don't have a good story for these issues. @glennjones
Glenn Jones
@tobie @adrianba @w3ctag its an issue with API design, developer expectations and documentation. Wrote post: http://bit.ly/1RkmWqP
Ade Bateman
@glennjones BTW, I expect IE11 to be around for a long time, but not IE10.
Tobie Langel
@adrianba well, according to @glennjones, there is: lots of try..catch wrapping in lieu of feature detection.
Robin Berjon
@glennjones Not wonderful, but you might be able to test window.URL.prototype.constructor.length or some such. @tobie @adrianba @w3ctag
Tobie Langel
@robinberjon I'm sure you meant window.URL.prototype.constructor.prototype.constructor.length. #bettersafethansorry @glennjones @adrianba

In reply to this conservation:
Glenn Jones
Find it a little sad some of the browser APIs are introduced in such an incomplete state the only way to use them is in try/catch blocks
Tobie Langel
@glennjones are these implementation issues or spec ones?
Glenn Jones
@tobie just looking at URL and URLUtils the constructor of URL takes 2 arguments to resolve absolute URL, but the early IE version blows up
Tobie Langel
@glennjones how to ship partial implementations that don't blow-up in devs' faces is something @w3ctag should help implementors with, imho.
@tobie @w3ctag its a hard problem, but when you start to see cross browser code examples like https://developer.mozilla.org/en-US/docs/Web/API/DOMParser… I do start to worry
‐ Also on:
Mentions:
Tobie Langel
@glennjones incidentally, that's why we need more tests. /cc @w3ctag

In reply to this conservation:
Glenn Jones
Find it a little sad some of the browser APIs are introduced in such an incomplete state the only way to use them is in try/catch blocks
Tobie Langel
@glennjones are these implementation issues or spec ones?
@tobie the examples for URL and URLUtils polyfills are having to use try/catch to get around this. Similar issues with DOMParser
‐ Also on:

In reply to this conservation:
Glenn Jones
Find it a little sad some of the browser APIs are introduced in such an incomplete state the only way to use them is in try/catch blocks
Tobie Langel
@glennjones are these implementation issues or spec ones?
@tobie just looking at URL and URLUtils the constructor of URL takes 2 arguments to resolve absolute URL, but the early IE version blows up
‐ Also on:
Mentions:
Tobie Langel
@glennjones that's a tough one indeed. What else could IE do not to cause that issue? /cc @adrianba
Tobie Langel
@adrianba agreed. Still, that makes it painful for devs. There must be a better way. @glennjones
Ade Bateman
Tobie Langel
@adrianba I don't know. Would not shipping a partial implementation help? @glennjones
Ade Bateman
@tobie @glennjones IE10+ only supported the static methods on URL so there is no constructor. At the time what else could it do but throw?
Tobie Langel
@adrianba sounds like the @urlstandard should have taken that in account then. @glennjones
Glenn Jones
@tobie @adrianba I don't known the history, but it does look like the URL object should not have been extended in this way, not a IE issue!
Ade Bateman
@glennjones @tobie It's complicated because I think things were proceeding in parallel. I actually don't think there is a problem here.
Tobie Langel
@adrianba well, according to @glennjones, there is: lots of try..catch wrapping in lieu of feature detection.
Tobie Langel
@adrianba I'm not blaming IE, btw. We just don't have a good story for these issues. @glennjones
Tobie Langel
@glennjones incidentally, that's why we need more tests. /cc @w3ctag
Glenn Jones
@tobie @adrianba @w3ctag its an issue with API design, developer expectations and documentation. Wrote post: http://bit.ly/1RkmWqP
Glenn Jones
@tobie @w3ctag its a hard problem, but when you start to see cross browser code examples like https://developer.mozilla.org/en-US/docs/Web/API/DOMParser… I do start to worry
Ade Bateman
@glennjones BTW, I expect IE11 to be around for a long time, but not IE10.
Tobie Langel
@glennjones how to ship partial implementations that don't blow-up in devs' faces is something @w3ctag should help implementors with, imho.
Robin Berjon
@glennjones Not wonderful, but you might be able to test window.URL.prototype.constructor.length or some such. @tobie @adrianba @w3ctag
Ade Bateman
@tobie @glennjones We shipped a complete implementation of what was in the File API spec at the time (which only defined static members).

Find it a little sad some of the browser APIs are introduced in such an incomplete state the only way to use them is in try/catch blocks
‐ Also on:
Mentions:
Tobie Langel
@glennjones are these implementation issues or spec ones?
Tobie Langel
@glennjones incidentally, that's why we need more tests. /cc @w3ctag
Ade Bateman
@tobie @glennjones IE10+ only supported the static methods on URL so there is no constructor. At the time what else could it do but throw?
Tobie Langel
@adrianba agreed. Still, that makes it painful for devs. There must be a better way. @glennjones
Glenn Jones
@tobie @w3ctag its a hard problem, but when you start to see cross browser code examples like https://developer.mozilla.org/en-US/docs/Web/API/DOMParser… I do start to worry
Tobie Langel
@adrianba I don't know. Would not shipping a partial implementation help? @glennjones
Ade Bateman
@tobie @glennjones We shipped a complete implementation of what was in the File API spec at the time (which only defined static members).
Tobie Langel
@adrianba sounds like the @urlstandard should have taken that in account then. @glennjones
Glenn Jones
@tobie @adrianba I don't known the history, but it does look like the URL object should not have been extended in this way, not a IE issue!
Ade Bateman
@glennjones @tobie It's complicated because I think things were proceeding in parallel. I actually don't think there is a problem here.
Tobie Langel
@glennjones how to ship partial implementations that don't blow-up in devs' faces is something @w3ctag should help implementors with, imho.
Tobie Langel
@adrianba well, according to @glennjones, there is: lots of try..catch wrapping in lieu of feature detection.
Tobie Langel
@glennjones that's a tough one indeed. What else could IE do not to cause that issue? /cc @adrianba
Tobie Langel
@adrianba I'm not blaming IE, btw. We just don't have a good story for these issues. @glennjones
Glenn Jones
@tobie the examples for URL and URLUtils polyfills are having to use try/catch to get around this. Similar issues with DOMParser
Glenn Jones
@tobie @adrianba @w3ctag its an issue with API design, developer expectations and documentation. Wrote post: http://bit.ly/1RkmWqP
Glenn Jones
@tobie just looking at URL and URLUtils the constructor of URL takes 2 arguments to resolve absolute URL, but the early IE version blows up
Ade Bateman
@glennjones BTW, I expect IE11 to be around for a long time, but not IE10.
Ade Bateman






Data formats:

API