Closed Bug 473976 Opened 16 years ago Closed 16 years ago

MozMill test breaks editBookmark popup initialization

Categories

(Firefox :: Bookmarks & History, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3.6a1

People

(Reporter: whimboo, Assigned: whimboo)

References

Details

Attachments

(3 files, 2 obsolete files)

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20090116 Shiretoko/3.1b3pre Ubiquity/0.1.4 ID:20090116020328 and MozMill latest trunk Running the attached Mozmill test under "firefox/bookmarks" results in breaking the editBookmarks popup. I don't know why that happens and if this is a bug in MozMill or a core issue. Mikeal or Adam, could you both please have a look at the test? If this is a core issue we should move it to the appropriate product/component later.
One further note. This issue can only be seen once within a Firefox session. You have to restart Firefox to see it again. Means my test it not totally wrong, but probably shows an issue which normally will not appear when manual testing this behavior.
Running the test for the first time shows following error and exceptions: Error: Error: could not find element ID: editBMPanel_folderMenuList Source File: file:///Volumes/Daten/mozilla/profiles/mozmill/extensions/mozmill@mozilla.com/resource/modules/frame.js Line: 342 Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsINavBookmarksService.getFolderIdForItem]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: chrome://browser/content/places/editBookmarkOverlay.js :: EIO_initPanel :: line 157" data: no] Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsINavBookmarksService.getItemTitle]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: chrome://browser/content/places/editBookmarkOverlay.js :: EIO__getItemStaticTitle :: line 415" data: no]
Ok, I've updated my code and waiting for editBMPanel_folderMenuList element before clicking on it. But I still think that this shouldn't break the initialization of the dialog. // Use menu to open the bookmark panel controller.menus.Bookmarks["Bookmark This Page"].click(); controller.waitForElement(new elementslib.ID(controller.window.document, "editBMPanel_folderMenuList")); // Bookmark URI under bookmarks menu controller.click(new elementslib.ID(controller.window.document, "editBMPanel_folderMenuList"));
This looks like a situation where when you try to access this node editBMPanel_folderMenuList before it's really done rendering, you can actually break it (or whatever code it is that is building it). I simply did this: controller.menus.Bookmarks["Bookmark This Page"].click(); controller.sleep(1000) The one second seems to get you over that little gap where things are still drawing. I don't necessarily think this is a bug in Windmill, but I will look at editBookmarkOverlay.js line 415 and see if there is anything we can automatically do to avoid this.
Can someone tell me where I can find editBookmarkOverlay.js in a web accessible source repo?
you can search the source repo by filename (or a substring of) like so: http://mxr.mozilla.org/mozilla-central/find?string=editbookmarkoverlay.js
Sure, you should use MXR to search on mozilla-central. Just enter the file name and hit search: http://mxr.mozilla.org/mozilla-central/ You will end up here: http://mxr.mozilla.org/mozilla-central/source/browser/components/places/content/editBookmarkOverlay.js Probably Marco can help us here, when he is back in an hour or so. Adam, I think using the waitforElement is a better way here and that also works for me without having to wait useless ~700ms.
That would be great, except on my machine your test using waitForElement is still broken the same way as if it's not there and is reproducibly broken. I tried many things and literally the only thing that I can do to get mine to not be broken is a 500-1000ms static sleep. Thanks for the pointers on searching the moz source.
so a small explanation of what happens when you click on the star or generally when you open a bookmark edit / add panel. The editBookmarkPanel is already present in all dialogs from the begin, it's part of the xul that defines the dialog, could hwv be that its contents are lazy loaded when first accessed, that could explain the mozmill first error. About the places errors, practically the internal editBookmarkPanel is initialized after the star panel, when you click the star (or open any other bookmarks dialog/panel) there is a small initialization of the external panel/dialog, then a bookmark is added through places api, and FINALLY the editBookmarkPanel gets initialized. (See http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser-places.js#169) So if you try to use the panel before it is initialized (through a call to initPanel), it cannot know what bookmark you're working for, internally its _itemId property is -1, and all calls to places backend will fail (and throw). Also the elements in the panel are collapsed at init, so you see them all since it was not inited. (see http://mxr.mozilla.org/mozilla-central/source/browser/components/places/content/editBookmarkOverlay.js#126) This should explain the 2 remaining places errors that you see. So what you should wait is that the panel is initialized, not that true... we could maybe add an attribute to editBookmarkPanel that will show its status, and you could poll it until you see it has been initialized.
Adam, do we have a function, which I can use to poll a given attribute?
We have the waitForEval function that takes a javascript expression and waits until it evaluates to true, we could do something as follows: waitForEval("subject.property == true", 1000, 100, editBookmarkPanelObject); So I certainly think the property would be a good solution to this, thanks Marco for the explanation and possible solutions!
Mmh using that function in the following way does not work: controller.waitForElement(new elementslib.ID(controller.window.document, "editBookmarkPanel")); controller.waitForEval("subject.property == true", 1000, 100, editBookmarkPanel); While the first call succeeds the second call to waitForEval states: "exception: ReferenceError: editBookmarkPanel is not defined"
that was just an example, subject would need to be a property that gets set when its finished lazy loading, it would be something like editBookmarkPanel.loaded
(In reply to comment #10) > So what you should wait is that the panel is initialized, not that true... we > could maybe add an attribute to editBookmarkPanel that will show its status, > and you could poll it until you see it has been initialized. That would be great. Something like "editBookmarkPanel.loaded" what Adam already proposed?
Attached patch patch v1.0 (obsolete) — Splinter Review
this should allow for: controller.waitForEval("subject.initialized == 'true'",1000, 100, new elementslib.ID(controller.window.document, "editBookmarkPanelContent"));
Attachment #357670 - Flags: review?(dietrich)
Assignee: nobody → mak77
Blocks: 474313
Component: Gristmill → Places
Product: Testing → Firefox
QA Contact: gristmill → places
Attachment #357670 - Flags: review?(dietrich) → review+
Comment on attachment 357670 [details] [diff] [review] patch v1.0 >+ _panel: null, >+ get panel() { >+ if (!this._panel) >+ this._panel = document.getElementById("editBookmarkPanelContent"); >+ return this._panel; > }, Since this is isn't a prototype object, you can use this pattern: > get panel() { > delete this.panel; > return this.panel = document.getElementById("editBookmarkPanelContent"); > },
Attached patch patch v1.1 (obsolete) — Splinter Review
addressed dao's comment
Attachment #357670 - Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Attachment #357934 - Flags: approval1.9.1?
Comment on attachment 357934 [details] [diff] [review] patch v1.1 asking approval, low risk
Target Milestone: --- → Firefox 3.2a1
i backed this out because it was not working as expected (still some strange behavior due to mozmill interaction with a lazy binding probably) and this added back the Library leak. Drew has created a test for the leak in bug 474831.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attachment #357934 - Attachment is obsolete: true
Attachment #357934 - Flags: approval1.9.1?
Whiteboard: [needs investigation on mozmilla behavior with lazy bindings]
Marco, we called the waitForEval function with the wrong object. The element which gets returned by elementslib is an elementslib object but not the real one, which shall be inspected. We have to call .getNode() to get the real element like you can see here: let elem = new elementslib.ID(controller.window.document, "editBookmarkPanel"); controller.waitForEval("subject.initialized === true", 1000, 100, editBookmarkPanel.getNode()); Using that way we should be able to correctly check for the initialized property.
Whiteboard: [needs investigation on mozmilla behavior with lazy bindings]
Sorry, hit Enter too early. Here the correct code: let e = new elementslib.ID(controller.window.document, "editBookmarkPanel"); controller.waitForEval("subject.initialized === true", 1000, 100, e.getNode());
thanks for clarification, still before going on we need 2 leak tests, one from bug 474831 and one from bug 433231.
i was just now looking at the code for the star UI, the internal overlay is loaded dynamically here http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser-places.js#166 so it's not available on first open, but the starUI object in the top window has a property _overlayLoaded that you could look at
so both the overlay is loaded lazily, and the internal panel (object gEditItemOverlay) is initialized later
Thanks for this great information Marco! Even I would feel better to use an element which is returned by the MozMill inspector, the given property from the StarUI works fantastic. That means we don't need a fix for the editBookmarksPanel right now. But if you think an update would simplify the query for other modules, feel free to give us an improvement. Clint, what do you think? It's a simple fix which prevent us from running into a timeout each time.
Assignee: mak77 → hskupin
Status: REOPENED → ASSIGNED
Attachment #362457 - Flags: review?(ctalbert)
at that point, you could also look at gEditItemOverlay.itemId and check its value is > 0 (that global object should exist in the window when the overlay is loaded)
Comment on attachment 362457 [details] [diff] [review] Using StarUI for waitForEval r= ctalbert This looks really good. Thanks whimboo!
Attachment #362457 - Flags: review?(ctalbert) → review+
Pushed to mozmill-tests: http://hg.mozilla.org/qa/mozmill-tests/rev/374c15ba1f06 Marco, any enhancements should to the panel itself should be handled in a new bug.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago16 years ago
Resolution: --- → FIXED
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h". In Thunderbird 3.0b, you do that as follows: Tools | Message Filters Make sure the correct account is selected. Click "New" Conditions: Body contains places-to-b-and-h Change the action to "Delete Message". Select "Manually Run" from the dropdown at the top. Click OK. Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter. Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: