Open Bug 1854873 Opened 9 months ago Updated 9 months ago

browser_invalidDbFolderLoad.js isn't failing. Should it?

Categories

(Thunderbird :: General, task)

Tracking

(Not tracked)

People

(Reporter: benc, Unassigned)

Details

I've got a rewrite of the folder parsing code (as part of my big mbox refactor), but it's causing a mochitest to fail.
The test is pretty small and simple:

browser_invalidDbFolderLoad.js

My new folder parsing is more strictly asynchronous that the current implementation.
I have a suspicion that the test is relying on the current implementation being a little more synchronous than it should be...

The be_in_folder() call triggers a folder.updateFolder() call, which in turn kicks off a folder reparse (which is supposed to be fully asynchronous).

In the existing code, be_in_folder returns after the folder parse is complete.

But with my changes, the folder parse is still running when be_in_folder returns, and the test then fails in assert_messages_in_view - reading folder.msgDatabase fails with an NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE (which indicates the parse is still running).

So.
Does be_in_folder have some special mechanism to ensure it waits until the folder parse triggered by UpdateFolder() has completed?
Or is the test actually wrong, and it's just a lucky quirk of the existing code which means the folder parse completes before be_in_folder returns?

Flags: needinfo?(geoff)

(In reply to Ben Campbell from comment #0)

Does be_in_folder have some special mechanism to ensure it waits until the folder parse triggered by UpdateFolder() has completed?
Or is the test actually wrong, and it's just a lucky quirk of the existing code which means the folder parse completes before be_in_folder returns?

Looks like it. This code calls updateFolder then nothing happens until we get notified about it finishing. This doesn't really answer the question, I got a bit sidetracked.

Flags: needinfo?(geoff)

I think that it's just luck. be_in_folder waits for folderURIChanged which would happen after updateFolder is called, but not necessarily before it calls back to say it's finished. assert_messages_in_view should fail if it's not finished.

I tried raising the number of messages used by the test to slow it down but didn't see any change in behaviour. Maybe the current code really is sync.

Oh here we go: Uncaught exception in test bound test_load_folder_with_invalidDB - [Exception... "Component returned failure code: 0x80550005 [nsIMsgFolder.msgDatabase]". The test doesn't like 30000 messages.

(In reply to Geoff Lankow (:darktrojan) from comment #3)

Oh here we go: Uncaught exception in test bound test_load_folder_with_invalidDB - [Exception... "Component returned failure code: 0x80550005 [nsIMsgFolder.msgDatabase]". The test doesn't like 30000 messages.

Cool! That's exactly the error I get when I have my new folder-parsing code in place, which has a fastidiously async folder ParseFolder() implementation.

You need to log in before you can comment on or make changes to this bug.