Closed Bug 666245 Opened 13 years ago Closed 13 years ago

Update shared modules for correct handling of the document loaded state introduced by bug 661408

Categories

(Mozilla QA Graveyard :: Mozmill Tests, defect)

defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: whimboo, Assigned: whimboo)

References

Details

Attachments

(3 files, 3 obsolete files)

As given on bug 661408 we have to remove the documentLoaded property from the DOMWindow due to namespace conflicts. Therefore our shared modules have to be updated to handle both cases for now. Later we can remove the support for documentLoaded inside the modal dialog class.
Attached patch Patch v1 (obsolete) — Splinter Review
I was able to get rid of the documentloaded state check for the handleWindow case but so far I haven't found a possibility for the modalDialog observer class. With this patch we support both ways (pre/post) the patch on bug 661408.

Once it has been reviewed I also have to update the file for the API refactored module.
Attachment #541050 - Flags: review?(gmealer)
Missed to revert to the try/catch clause for the check if the window has been loaded. Here the real version.
Attachment #541050 - Attachment is obsolete: true
Attachment #541052 - Flags: review?(gmealer)
Attachment #541050 - Flags: review?(gmealer)
Comment on attachment 541052 [details] [diff] [review]
Patch v1.1 [checked-in]

>+    try {
>+      controller = new mozmill.controller.MozMillController(window);
>+    ...
>+    }
>+    catch (ex) {
>+    }

I'm really not a fan of catch-all exception handlers that don't reraise, though I'd let it go by for a workaround.

Otherwise looks fine. r+
Attachment #541052 - Flags: review?(gmealer) → review+
This has caused a regression with all the Discovery Pane tests. Specifically, it appears that the test is timing out in modalDialog.observe() waiting for window.isLoaded even though the dialog is appearing.
Blocks: 657492
Blocks: 657496
Blocks: 657497
Blocks: 658365
Blocks: 664018
Blocks: 664019
The issue here is not my patch but Mozmill itself. With my code change we also pass a null value as window into its constructor. That causes Mozmill to stop execution and the whole thread stalls. I will attach a workaround patch for now in a couple of minutes. The real issue is now handled on bug 668202.
Depends on: 668202
Comment on attachment 542802 [details] [diff] [review]
Follow-up to circumvent bug 668202 [checked-in]

Check for non null window looks fine to me, r+
Attachment #542802 - Flags: review?(aaron.train) → review+
Attachment #541052 - Attachment description: Patch v1.1 → Patch v1.1 [checked-in]
Depends on: 668221
A Pivotal Tracker story has been created for this Bug: https://www.pivotaltracker.com/story/show/15285157
For Mozmill 2 and our API refactoring the isLoaded() method should be available on the window wrapper. I will come up with a patch on Monday.
Attached patch Patch v1 (API refactor) (obsolete) — Splinter Review
Patch against the API refactoring repository. I have had to always use static calls to avoid extra instantiation of a window wrapper class, and there is no way to call a method bound to the prototype from the constructor of the same class.
Attachment #546750 - Flags: review?(gmealer)
Attachment #546750 - Attachment description: Patch v1 → Patch v1 (API refactor)
Comment on attachment 546750 [details] [diff] [review]
Patch v1 (API refactor)

A couple of problems.

First,

Static methods in Javascript are typically added to the function itself, not to the prototype. The idea is that it's not something owned by an instance at all, it's owned by the "class" (that is, the constructor function, in Javascript).

http://stackoverflow.com/questions/1635116/javascript-class-method-vs-class-prototype-method

function SomeClass() { ... }

SomeClass.staticMethod = function () { ... }

foo = SomeClass.staticMethod()

Second,

You can't have a static method that refers to "this" where "this" is an object instance (in your case, a window wrapper). You don't have an object instance. In a static method, "this" would refer to the constructor function (in a more classical OOP language, it'd be the "class" entity).

If someone were to ever call that without defining win, it'd fail spectacularly due to the default handling code.

A couple of options:

You can move this up to be a true static method and take out any default handling so there are no references to "this". But we don't have many static methods.

My preference would probably be for you to make this a (probably) non-exported utility function within the module, then expose it as an object method:

function winIsLoaded(aDOMWindow) {
  return ("mozmillDocumentLoaded" in aDOMWindow) && aDOMWindow.mozmillDocumentLoaded;
}

ChromeWindowWrapper.prototype.isLoaded() {
  return winIsLoaded(this.innerWindow);
}

If you want something available in our API to use against arbitrary DOMWindows, expose the utility method publicly (or make it a static method, I guess). It's a little weird to have the wrapper instance take other windows and tell you if they're loaded; it should only deal with itself.

BTW, did you mean for a window not to be considered loaded if we're not on Mozmill tip? Wasn't there supposed to be an either-or to the logic there, rather than just looking for the new property?

A smaller issue, btw: we're inconsistent as to what aWindow means in that file in particular. Sometimes it means a DOMWindow, and sometimes it means a window wrapper. I'd like us to find consistent naming we like and use it everywhere. 

Let's pick names and then I can make the changes globally. I'd prefer aDOMWindow vs. either aWrapper or aWindow.
Attachment #546750 - Flags: review?(gmealer) → review-
(In reply to comment #13)
> Static methods in Javascript are typically added to the function itself, not
> to the prototype. The idea is that it's not something owned by an instance
> at all, it's owned by the "class" (that is, the constructor function, in
> Javascript).

In that case we will not be able to have a static method because with the upcoming WindowWrapper base class there would be no way to call the method from the sub classes. I see it now.

> My preference would probably be for you to make this a (probably)
> non-exported utility function within the module, then expose it as an object
> method:

Right. That's the best way to go. Will come up with a new patch shortly.

> BTW, did you mean for a window not to be considered loaded if we're not on
> Mozmill tip? Wasn't there supposed to be an either-or to the logic there,
> rather than just looking for the new property?

No-one except us is using the API refactored code. There is no need for the fallback code. We will have to always use at least Mozmill 1.5.4b6.

> A smaller issue, btw: we're inconsistent as to what aWindow means in that
> file in particular. Sometimes it means a DOMWindow, and sometimes it means a
> window wrapper. I'd like us to find consistent naming we like and use it
> everywhere. 

Lets do it in the patch when I create the new base class. I can then take care of it.
Attached patch Patch v2 (API refactor) (obsolete) — Splinter Review
Updated patch. I have exported isWindowLoaded because it could still happen that a test would need direct access to it.
Attachment #546750 - Attachment is obsolete: true
Attachment #547048 - Flags: review?(gmealer)
Attachment #547048 - Attachment is obsolete: true
Attachment #547049 - Flags: review?(gmealer)
Attachment #547048 - Flags: review?(gmealer)
Comment on attachment 547049 [details] [diff] [review]
Patch v2.1 (API refactor)

Looks great, r+. Thanks for the changes and the explanation on the fallback. I agree.
Attachment #547049 - Flags: review?(gmealer) → review+
Landed on the API refactoring repository:
https://github.com/geoelectric/mozmill-api-refactor/commit/fe07bd3ab8b9f2448db0ef850689ab987c881ee9
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: