Closed Bug 483781 Opened 16 years ago Closed 16 years ago

make tests that require the toolkit dlmgr UI not fail with new SeaMonkey dlmgr UI work

Categories

(Toolkit :: Downloads API, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: kairo, Assigned: kairo)

References

Details

(Keywords: fixed1.9.1)

Attachments

(1 file, 1 obsolete file)

Bug 381157 will make SeaMonkey implement its own implementation of nsIDownloadManagerUI, ultimately pointing to the new tree-based DM window created in bug 472001. The problem that arises with that is that SeaMonkey will fail all tests in toolkit that require the toolkit UI. The solution we have come up with is to implement a hidden pref in our nsIDownloadManagerUI implementation that will switch us to use the toolkit UI. The name of browser.download.manager.useToolkitUI is generic enough that everyone else doing a similar thing (Fennec?) could do the same. Now, to not make tests fail, those that actually need it, should also set this pref to true so that they get the UI they expect. Ideally, this can land on 1.9.1 before SeaMonkey lands bug 381157 and bug 472001 so our test boxes never need to go orange for this.
My latest patch on Bug 472001 enables the SeaMonkey use of this pref, (but does depend on review of Bug 381157). I tested that if the pref is set that these tests pass, regardless of the SeaMonkey browser.download.manager.behavior setting. The following tests were tested by me: _CHROME_FILES = \ test_basic_functionality.xul \ test_cleanup_search.xul \ test_clear_button_disabled.xul \ test_close_download_manager.xul \ test_delete_key_removes.xul \ test_esc_key_closes_clears.xul \ test_multi_select.xul \ test_multiword_search.xul \ test_pause_button_state.xul \ test_removeDownload_updates_ui.xul \ test_search_clearlist.xul \ test_search_keys.xul \ test_select_all.xul \ test_space_key_pauses_resumes.xul \ test_ui_stays_open_on_alert_clickback.xul \ test_unkownContentType_dialog_layout.xul \ test_bug_412360.xul \ test_bug_429247.xul \ The only one of these that this pref is not needed for is test_unkownContentType_dialog_layout.xul The mac-only test: test_backspace_key_removes.xul I suspect will need this pref, but did not test. Ideally these tests will set this pref, and reset it when they finish. I am not sure the best way to go about that in the tests themselves though.
This patch sets the pref while executing the tests and clears it again when finishing every test. This doesn't affect Firefox at all as it doesn't listen to that pref but SeaMonkey stays green with that patch even when the patches in bug 472001 land and any other toolkit-based app that ships with a different dlmgr implementation can implement the pref the same way and get the same effect :)
Assignee: nobody → kairo
Status: NEW → ASSIGNED
Attachment #372999 - Flags: review?(sdwilsh)
Attachment #372999 - Flags: review?(sdwilsh) → review-
Comment on attachment 372999 [details] [diff] [review] set .useToolkitUI=true while executing the UI tests So, we may have talked about this on irc, and I may have said it was OK (I think that's the case, but I'm not sure). However, thinking about this some more, I'm not happy with the setup. New tests will have to do the same thing, but won't fail on Firefox, where people are likely adding the tests. I'm going to suggest we make a utility js file, like http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/downloads/tests/chrome/utils.js, and define dmui a method, like getDMUI (better names welcome), that will return the service. The trick is to get the service by classID, which shouldn't ever change, and if it does, I'd want the tests to fail anyway. Make sense?
(In reply to comment #3) > The trick is to get the service by classID, which shouldn't ever > change, and if it does, I'd want the tests to fail anyway. As explained on IRC, that might work nice we we would package both the toolkit and the SeaMonkey service, which would work nicely if we were a XULRunner app - but here's the caveat: We aren't, so we would have to deliver them in the same directory and component manager isn't predictable in the order in which it loads components from the same directory, which means we wouldn't know which UI would override which one and be used. Because of that, we need to go ugly and not ship the toolkit implementation of nsIDownloadManagerUI and we can't grab it right there. D'Oh! With that situation, I'm not really sure of a better solution than the patch I attached here.
How about this: Make a utility function that checks if we have the classID in Components.classesById and returns a boolean. Add that to the start of every test and bail early if it returns false. No preference setting, and resetting needed.
Per IRC, we'll just resort to not running those tests in SeaMonkey for now, with an ifdef in the toolkit Makefile. Patch upcoming as soon as I am sober, awake and have time :)
sdwilsh, would setting this pref in the toolkit/ head.js (auto-included in every test) be ok? we can unset in the cleanup() function (we'd set it AFTER the first-auto-run of cleanup) And in *our* (seamonkey) DLMGR tests we do similarly but just resetting it if set?
Callek, I somehow feel it would be too unclean to not ensure things are cleaned up in *every* test that also calls the setting of the pref. We've had enough bugs already on one test changing execution of another by not cleaning up correctly, I don't want to introduce more of that. I feel better with SeaMonkey not testing toolkit UI automatically than with polluting the pref set of other tests.
Summary: set browser.download.manager.useToolkitUI=true in tests that require the toolkit dlmgr UI → make tests that require the toolkit dlmgr UI not fail with new SeaMonkey dlmgr UI work
The real fun is here - the new patch actually combined what Shawn says in comment #3 and comment #5 ;-) It turns out that while we aren't _packaging_ nsDownloadManagerUI.js, we are actually building it. So when running tests from dist/bin, it's actually there, when running them (potentially) from a packaged build, it's not. With this in mind, I made the utility function for getting the UI (by CID) just return false if the class ID is not found. With this, we can easily either bail out prematurely and note that in logs with a todo() or actually force going through the toolkit service if it exists. I tested this both with nsDownloadManagerUI.js present in components/ and not and on both SeaMonkey with the dlmgr patches and Minefield and all 4 (!) variants work without failures, either passing all tests or returning a todo() for all (with the exception of the test for private browsing that always returns todo on SeaMonkey).
Attachment #372999 - Attachment is obsolete: true
Attachment #374781 - Flags: review?(sdwilsh)
Comment on attachment 374781 [details] [diff] [review] v2: ensure going through toolkit CID nit: @returns instead of @return r=sdwilsh
Attachment #374781 - Flags: review?(sdwilsh) → review+
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Keywords: fixed1.9.1
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
Blocks: 495629
No longer blocks: 495629
Depends on: 495629
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: