Closed Bug 371026 Opened 19 years ago Closed 19 years ago

reftest: double setTimeout from onload is not late enough for some tests

Categories

(Testing :: Reftest, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: asqueella, Assigned: asqueella)

Details

Attachments

(1 file, 3 obsolete files)

bug 369319 made reftest drawWindow from a setTimeout called from a setTimeout called from an onload hanlder. This is not enough for some tests I was creating (they involve document.loadOverlay - bug 330458). There should be something similar to mochitest's SimpleTest.waitForExplicitFinish() / SimpleTest.finish(), which can be used by tests to indicate they're doing things asynchronous and specify the moment reftest should make a snapshot of the page. Let me know if this is a bad idea for some reason.
Is there a compelling reason for adding this in?
OS: Windows XP → All
Hardware: PC → All
See comment 0. Some tests (e.g. ones involving document.loadOverlay, which is async) don't work with the current setup. Not to mention this double-setTimeout is a hack too. And it's different from mochitest for no reason.
This is ok with me as long as we only have to add stuff to tests or references that require delay (and can leave the bulk of the tests untouched). (328829-1 counts as a test that requires a delay.)
Perhaps such tests should fire a "refteststart" event at onload? If that event's detected before the double setTimeout fires, it puts the test into wait mode. The rendering is captured when the test fires a "reftestcomplete" event. I don't have time to code this, but is there any reason this shouldn't work?
DOM events API is unfortunately too verbose to use. What I am going to do instead is have the asynchronous tests have a class='reftest-wait' on their root element, and once they're ready, they'll remove the class with |document.documentElement.className = ""| (which is unfortunately quite verbose too and isn't very obvious). The reftest runner will detect these changes in a mutation observer and run the comparison (in a setTimeout(..., 0)). Feel free to steal this from me.
Assignee: nobody → asqueella
Attached patch patch (obsolete) — — Splinter Review
If this is good to go, I'll also update documentation. Should this go to README? I don't really like in-tree documentation...
Attachment #256390 - Flags: superreview?(dbaron)
Attachment #256390 - Flags: review?(dbaron)
Just two comments, I think: (1) className.indexOf("reftest-wait") should be (in two places, I think) className.split(/\s+/).indexOf("reftest-wait") since the class attribute is a whitespace-separated list of keywords. See http://www.w3.org/TR/html4/struct/global.html#h-7.5.2 (And it's probably better to test "!= -1" rather than "> -1".) (2) you should have a newline at the end of the test file, rather than "\No newline at end of file". (Unix convention is for newline to be a line *terminator*, which allows distinguishing between a 0-line file and a file with 1 empty line. In other words, text files are either empty or end with a line feed. Windows convention is to use carriage return + line feed as a line *separator*. So in Windows editors (and I think traditional Mac editors) you need to hit enter an extra time to do something that's properly portable to Unixish systems.) At some point we should probably switch back to a single setTimeout and switch the one test that needed it to use reftest-wait, but that can wait for a followup patch. And, yes, you should update the README.
Whiteboard: needs new patch
The README should encourage the use of the statement "document.body.offsetWidth;" rather than setTimeout when possible.
Attached patch HTML and XUL async tests (obsolete) — — Splinter Review
Decided to put these into their own directory.
Attached patch patch v2 (obsolete) — — Splinter Review
Attachment #256390 - Attachment is obsolete: true
Attachment #257159 - Flags: review?(dbaron)
Attachment #256390 - Flags: superreview?(dbaron)
Attachment #256390 - Flags: review?(dbaron)
(Added the other missing newline locally.. sigh)
Status: NEW → ASSIGNED
Whiteboard: needs new patch → r?
Comment on attachment 257158 [details] [diff] [review] HTML and XUL async tests r=dbaron with the newline fixed
Attachment #257158 - Flags: review+
Comment on attachment 257159 [details] [diff] [review] patch v2 Could you wrap the lines in the readme at 72 characters? They look a bit wider than the rest of the text. And perhaps call the section "Asynchronous Tests", and make the ===== line up? With that, r=dbaron. Not sure why you had to make this two separate patches, though.
Attachment #257159 - Flags: review?(dbaron) → review+
You can't get a diff with a new directory unless you cvs add that directory which I don't like doing, especially when the tree checked out via public cvs.
Whiteboard: r? → to fix nits + check in
mozilla/layout/reftests/reftest.list 1.66 mozilla/layout/reftests/reftest-sanity/reftest.list 1.1 mozilla/layout/reftests/reftest-sanity/test-async-ref.html 1.1 mozilla/layout/reftests/reftest-sanity/test-async-ref.xul 1.1 mozilla/layout/reftests/reftest-sanity/test-async.html 1.1 mozilla/layout/reftests/reftest-sanity/test-async.xul 1.1 mozilla/layout/tools/reftest/README.txt 1.5 mozilla/layout/tools/reftest/reftest.js 1.16
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Whiteboard: to fix nits + check in
Attached patch as checked in — — Splinter Review
Attachment #257158 - Attachment is obsolete: true
Attachment #257159 - Attachment is obsolete: true
Flags: in-testsuite+
Component: Testing → Reftest
Flags: in-testsuite+
Product: Core → Testing
Version: Trunk → unspecified
QA Contact: testing → reftest
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: