Closed Bug 1207702 Opened 9 years ago Closed 9 years ago

Fix a bug in test_promises_object_timetosettle-02.js.

Categories

(DevTools :: Debugger, defect)

defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
Firefox 45
Tracking Status
firefox45 --- fixed

People

(Reporter: ejpbruel, Assigned: ejpbruel)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

While refactoring the script actors to use protocol.js in bug 1037992, this test started failing for me. After some investigation, there seem to be a couple of things wrong with this test:

- The test sends an attach request to a promise front. The attach handler of the   
  promise actor eventually calls createSourceActors on TabSources. TabSources   
  needs this._thread to be set to the ThreadActor in order to work properly. 
  This field won't be set until we attach to a Chrome or TabActor. Nowhere in 
  the test do we actually attach to either of these. I'm not sure why the test 
  worked before, but it seems to be by pure chance: making a minor change in one 
  of the script actors causes this to fail. Explicitly attaching to either the 
  Chrome or TabActor makes the problem go away again.
- If that were the only problem, we could simply fix the test. However, the test
  checks that it always takes about 100ms for the promise to settle. I don't
  understand how we can actually guarantee this, and it seems likely to me that
  in fact were not, and again this only happens to work by chance. After fixing
  the above issue, promise settle time occasionally rises to 200-300ms, causing
  the test to fail intermittently.

Given these issues, I'd argue that the test is probably fundamentally broken, and needs to be rethought. Given that this test is blocking me on bug 1037992, I'd like to suggest that we disable it in the meantime.
See comment #1.
Attachment #8665009 - Flags: review?(jryans)
Blocks: 1037992
What if we just assert time to settle is >= 100ms? I think that is much more sane.
(In reply to Nick Fitzgerald [:fitzgen][:nf] from comment #2)
> What if we just assert time to settle is >= 100ms? I think that is much more
> sane.

If we can do that, that's fine with me too. In that case, we probably don't have to disable this test.
Comment on attachment 8665009 [details] [diff] [review]
Disable test_promises_object_timetosettle-02.js

Canceling review while I come up with a fix instead.
Attachment #8665009 - Flags: review?(jryans)
Turns out I was just being stupid and didn't understand how ChromeActor works. Here's a patch that fixes the issues explained in comment #1. I've used your suggestion to check that time to settle is >= 100ms, which is indeed much more sane.
Attachment #8665009 - Attachment is obsolete: true
Attachment #8685994 - Flags: review?(nfitzgerald)
Blocks: 1223766
Summary: test_promises_object_timetosettle-02.js seems to be buggy → Fix a bug in test_promises_object_timetosettle-02.js.
Blocks: 1212797, 1214248
Comment on attachment 8685994 [details] [diff] [review]
Fix a bug in test_promises_object_timetosettle-02.js.

Review of attachment 8685994 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks!

::: devtools/server/tests/unit/test_promises_object_timetosettle-02.js
@@ +24,5 @@
>  
>    let response = yield listTabs(client);
>    let targetTab = findTab(response.tabs, "test-promises-timetosettle");
>    ok(targetTab, "Found our target tab.");
> +  yield attachTab(client, targetTab);

I think you may need to attach to the thread as well, for the tab's sources to show up.

@@ +48,5 @@
>      events.on(front, "promises-settled", promises => {
>        for (let p of promises) {
>          if (p.promiseState.state === "fulfilled" &&
>              p.promiseState.value === resolution) {
> +          let timeToSettle = Math.floor(p.promiseState.timeToSettle / 100) * 100;

I think you can remove the flooring and arithmetic here now.
Attachment #8685994 - Flags: review?(nfitzgerald) → review+
https://hg.mozilla.org/mozilla-central/rev/dd627c83397a
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: