Bug Tracker

Opened 7 years ago

Closed 4 years ago

#10198 closed feature (migrated)

Run jQuery unit tests in XHTML

Reported by: dmethvin Owned by:
Priority: high Milestone: 1.next/2.next
Component: build Version: 1.6.3
Keywords: Cc:
Blocked by: Blocking:


We need to run the unit tests with an XHTML doctype to ensure that everything passes.

Change History (18)

comment:1 Changed 7 years ago by dmethvin

Component: unfiledbuild
Milestone: None1.7
Owner: set to dmethvin
Priority: undecidedblocker
Status: newassigned

comment:2 Changed 7 years ago by dmethvin

Milestone: 1.71.8

comment:3 Changed 7 years ago by dmethvin

Milestone: 1.81.next
Priority: blockerhigh

Still searching for a good solution, but this isn't a blocker.

comment:4 Changed 6 years ago by dmethvin

Ref #12359

comment:5 Changed 6 years ago by tomgrohl

Is it a case of copying all the tests and changing the doctype to xhtml, or is it limited to certain test.

I might be able to help on this one.

comment:6 Changed 6 years ago by dmethvin

That's part of the investigation to be done.

For example, we support Firefox and you can serve XHTML with the right docttype and HTTP Content-Type to ensure it's interpreted as XHTML, but it just spits out console warnings if you get it wrong according to #12359. Our automated tests wouldn't catch that type of problem.

On the other hand, in #12357 it seems a Firefox XUL application demands correct XHTML to run at all. We don't have XUL on our automated tests so there's no formal support for it, but we've been able to keep it running except when we break XHTML by accident as we've done a couple of times now. There have been similar reports related to Chrome plugins.

Perhaps we can just provide some sort of XUL test in Testswarm, since that seems to be the most sensitive environment.

comment:7 Changed 6 years ago by tomgrohl

Thanks for the info.

I'll have a look into it, see what else I can find.

comment:8 Changed 6 years ago by tomgrohl


As a starting point, I've wrote some code to check for content type and doctype.

It detects if closing tags / quoted attributes are required based on the following:

1 - content type is application/xhtml+xml 2 - content type is text/html and doctype is XHTML 3 - document is xul (Needs more testing though)

Generally is a doctype and/or content type is omitted it detaults to text/html.

This logic will be good to use and probably fix #12359 as well.

I'll now work on creating some tests for xhtml (based on the existing ones) and see where I get.

comment:9 Changed 6 years ago by dmethvin

Type: enhancementfeature

Bulk change from enhancement to feature.

comment:10 Changed 6 years ago by dmethvin

Owner: dmethvin deleted
Status: assignedopen

comment:11 Changed 6 years ago by dmethvin

Add IE10 to the list of browsers that will generate console warnings when there are doctype-related errors. Those happen too early for a shim to console.warn to see them.

comment:12 Changed 6 years ago by dmethvin

Although I wonder whether the shim would see them in a delay-loaded iframe.

Anway, https://github.com/jquery/jquery/commit/c6a694e1c262acb941b7fd86663f186656496bbc#commitcomment-2975014

comment:13 Changed 5 years ago by m_gol

Milestone: 1.next1.next/2.next

comment:14 Changed 5 years ago by anthonyryan1@…

Firstly a note: The majority of the regressions in XHTML compatibility over the past few years have been in feature / bug detection code included in jQuery.

There are two approaches we can take to solving this problem, neither of which is particularly ideal:

We can run the entire test suite in XHTML mode:


  • No duplicate tests required in the test suite.
  • All code paths are properly tested


  • Looking through the QUnit code history, they are extremely regression prone with XHTML compatibility. We could expect regular breakage when updating QUnit unless they are similarly encouraged to test XHTML support.
  • The test running interface uses document.write() and would need to be re-implemented in a better way.
  • Some unit tests may not be possible in XHTML mode, they would require some form of indicator that they should not be run in XHTML mode.
  • As a result of the previous, some tests may be marked incompatible with XHTML when they could work just fine out of developer laziness or misunderstanding.
  • Increases the test-running time by requiring the entire suite be run mulitple times
  • iframes tests will be immune to XHTML mode setup in this way, since the iframe has it's own context. This would result is tests passing when they should fail.

Alternatively, we can duplicate specific tests to be run in XHTML iframes:


  • None


  • Code coverage will be poor
  • Tests will be duplicated from their HTML counterparts
  • Maintaining a list of what should be duplicated will be a maintenance burden on jQuery.

comment:15 Changed 5 years ago by dmethvin

@anthonyryan, thanks for taking another look at this. I agree that none of the solutions are ideal, and it does get harder now that we are doing the feature detects on an as-needed basis. I'm thinking we may still want to do some sort of basic-functionality test with XHTML, at least it would give us some hope of avoiding these kind of recurring regressions.

comment:16 Changed 5 years ago by gibson042

True, just loading jQuery in an iframe and invoking the parent callback on successful load would go a long way. Per-module tests can come later, and need not be much more complicated either.

comment:17 in reply to:  15 Changed 5 years ago by m_gol

Replying to dmethvin:

@anthonyryan, thanks for taking another look at this. I agree that none of the solutions are ideal, and it does get harder now that we are doing the feature detects on an as-needed basis.

In test/support.js we force-compute all support tests to check if they match our expected matrix so that's not a problem.

comment:18 Changed 4 years ago by m_gol

Resolution: migrated
Status: openclosed
Note: See TracTickets for help on using tickets.