Can anyone see why this tests is valid?

23 views
Skip to first unread message

Domenic Denicola

unread,
Oct 10, 2012, 12:24:32 AM10/10/12
to js...@googlegroups.com
The following looks like it should NOT give a parser error, even though the test is expecting it.

  parser_failure_tag_in_text_content : function(test) {
    var thrown = false;
    try {
      var doc = jsdom.jsdom('\
<SCRIPT TYPE="text/javascript"> \
document.write("<SCR"+"IPT TYPE=\'text/javascript\' SRC=\'...\'><\/SCR"+"IPT>");\
</SCRIPT>');
    } catch (e) {
      thrown = true;
    }

    test.ok(doc.errors.length === 1);
    test.ok(doc.errors[0].message === "invalid markup");
    test.ok(thrown === false);
    test.done();
  }

Any ideas why the tests would be expecting it? I tried bisecting to find the first place this started failing, but it looks like it's been failing ever since it was introduced.

Elijah Insua

unread,
Oct 10, 2012, 2:59:21 AM10/10/12
to js...@googlegroups.com
This is a flawed attempt to ensuring all errors are captured. This test is based on a flaw in the parser which causes this test to log a 'Invalid character in tag name: "+"' error.  I believe it was a test case gleaned from a user, but that was a year ago :).

Ideally, we push this upstream (assuming it isn't a jsdomism) to htmlparser.  To be completely honest with you, I'd love to see jsdom use Arial's html5 parser by default.  I've wanted this for years but there always seems to be some sort of hurdle (i.e. jsdom is too strict for the tag/attribute names html5 is going to throw at it).

Domenic Denicola

unread,
Oct 10, 2012, 3:02:33 AM10/10/12
to js...@googlegroups.com

Hmm, OK. But there are no errors now (i.e. doc.errors is undefined, which is causing the test failure). Maybe htmlparser fixed itself?? Do you think this test can be removed?

 

I agree on switching parsers; after looking through the issues list, that seems like it would help with quite a lot. It’s on my medium-term to-look-into list, after a Sizzle replacement to fix all our querySelector problems. Good to know what the issues might be though.

Elijah Insua

unread,
Oct 10, 2012, 3:12:03 AM10/10/12
to js...@googlegroups.com
Killed it with fire!

Domenic Denicola

unread,
Oct 10, 2012, 3:12:57 AM10/10/12
to js...@googlegroups.com

Yessss down to 100 open issues.

Reply all
Reply to author
Forward
0 new messages