RE: getting your tests into browser test framework

Did you see the setup I got from Simon? 

function test_resolve(name, base, rel, expected, host) {
  if (name === '') name = JSON.stringify(base) + "+" + JSON.stringify(rel);
  var t = async_test(name);
  var iframe = document.createElement('iframe');
  document.body.appendChild(iframe);
  var doc = iframe.contentWindow.document;
  iframe.onload = function(){
    t.step(function() {
      assert_equals(doc.getElementsByTagName('a')[0].href, expected);
      this.done();
    });
    document.body.removeChild(iframe);
  }
  doc.open();
  doc.write('<!doctype html><base href="'+ quote(base) + '"><a href="' + quote(rel) + '"></a>');
  doc.close();
}


And then 

test_resolve('space in path', 'http://example.org/', 'foo bar', 'http://example.org/foo%20bar');
test_resolve('space in fragment', 'http://example.org/', '#foo bar', 'http://example.org/#foo bar');

and the first few examples from your xml file:


test_resolve('', 'http://www.example.com/#', 'hello, world', 'http://www.example.com/hello,%20world');
test_resolve('', 'http://www.example.com/#', '\u00c2\u00a9', 'http://www.example.com/%C3%82%C2%A9');
test_resolve('', 'http://www.example.com/#', '\ud800\udf00ss', 'http://www.example.com/%F0%90%8C%80ss');
test_resolve('', 'http://www.example.com/#', '\u0041\u000a', 'http://www.example.com/A');
test_resolve('', 'http://www.example.com/#', '\ud800\u597d', 'http://www.example.com/%EF%BF%BD%E5%A5%BD');
test_resolve('', 'http://www.example.com/#', 'a\uFDD0', 'http://www.example.com/a%EF%B7%90');
test_resolve('', 'http://www.example.com/#', 'asdf#qwer', 'http://www.example.com/asdf#qwer');
test_resolve('', 'http://www.example.com/#', '#asdf', 'http://www.example.com/#asdf');
test_resolve('', 'http://www.example.com/#', 'a\u000Ab\u000Dc\u0009d', 'http://www.example.com/abcd');



> -----Original Message-----
> From: Chris Weber [mailto:chris@lookout.net]
> Sent: Monday, October 29, 2012 3:12 AM
> To: Simon Pieters
> Cc: Larry Masinter; julian.reschke@gmx.de; jet@junglecode.com
> Subject: Re: getting your tests into browser test framework
> 
> On 10/28/2012 8:28 AM, Simon Pieters wrote:
> > On Sun, 28 Oct 2012 10:29:57 +0200, Larry Masinter <masinter@adobe.com>
> > wrote:
> >
> >> I don't think it's necessary to convert your tests to JSON to get them
> >> into the test framework...
> >> My understanding is that it would be quite possible to just read in
> >> the XML test cases and execute them.
> >
> > Indeed.
> 
> Ya, if my references to testharness.js and the W3C testing framework
> were correct, then I could just do this server-side using PHP.  I'd
> prefer to get these into JSON anyway, for straight client-side testing
> (plus I had some encoding issues with XML), which shouldn't be too hard.
> 
> 
> >> Let's talk about this on the public-iri list, and/or the testing
> >> interest group?
> 
> Okay, I'm going to write up an outline of the approach I used in my lab,
> which mirrors some of what others have already done plus some additional
> stuff I added.  I'll post that to the list.
> 
> >
> > iframe+<base>+<a href> and reading back .href seemed like a
> > cross-browser way to do it.
> 
> Okay that could work.  In my lab I was simply loading a new page for
> each test case, I didn't want to rely on iframes.  But I think this
> could work and only require the initial page-load.  I'll post details
> soon and ask for more feedback from you.
> 
> Best regards,
> Chris

Received on Monday, 29 October 2012 07:31:28 UTC