Closed Bug 572458 Opened 14 years ago Closed 14 years ago

tabs iterator test's onOpen not firing on linux under some circumstances

Categories

(Add-on SDK Graveyard :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: dietrich, Assigned: myk)

References

Details

Attachments

(1 file)

myk was seeing this, but i was not able to reproduce it.
Blocks: 572302
I just tested on Windows (7), and I see the problem there too.  It happens when I use |-F tab| to test both tabs and tab-browser, and it's the same on both trunk and branch builds of Firefox:

  error: TEST FAILED: test-tabs.testTabsIterator (empty test)

In theory, the test would have to time out to produce this result, but if every period in the test output represents a test being run, then I don't think the test harness waits long enough between the previous period and this error message for the test to actually be timing out.

Neither |-F tabs| (testing only tabs.js) nor |-F tab-browser| (testing only tab-browser.js) exhibit the problem.
Sounds like maybe the test isn't running at all, since it's configured to wait until test.done() is called. Can you confirm that the test body is actually being executed?
Yup, the test body is actually being called.  My hacked test looks like this:

--------------------------------------------------------------------------------
// test tabs iterator
exports.testTabsIterator= function(test) {
  test.waitUntilDone();
  openBrowserWindow(function(window, browser) {
    let tabs = require("tabs");
    let startCount = 0;
    for each (let t in tabs) startCount++;
    let url = "data:text/html,default";
    tabs.open(URL(url));
    tabs.open(URL(url));
console.log("about to open third tab");
    tabs.open({
      url: URL(url),
      onOpen: function(tab) {
console.log("onOpen");
        let count = 0;
        for each (let t in tabs) count++;
        test.assertEqual(count, startCount + 3, "iterated tab count matches");
        closeBrowserWindow(window, function() test.done());
      }
    });
  });
};
--------------------------------------------------------------------------------

When I run -F tab, I see "about to open third tab" but not "onOpen" in the console.  But when I run -F tabs, I see both messages in the console.
Strangely, when I remove one of the |tabs.open(URL(url))| calls, onOpen does get called.
I tracked down the problem.  test-tabs.testTabsIterator was finishing prematurely because test-tab-browser.testTabTracker was calling test.done() while test-tabs.testTabsIterator was running.

And test-tab-browser.testTabTracker was apparently calling test.done() because the TabTracker it instantiated was never unloaded, and it called test.done() any time the number of tracked tabs was reduced to one.

This patch unloads the TabTracker instantiated in test-tab-browser.testTabTracker once that test is done.  With this patch, I no longer see the test failure in test-tabs.testTabsIterator.
Assignee: nobody → myk
Status: NEW → ASSIGNED
Attachment #452103 - Flags: review?(dietrich)
Comment on attachment 452103 [details] [diff] [review]
patch v1: fixes problem

should unload before calling test.done(). r=me with that fixed. thanks for tracking this down!
Attachment #452103 - Flags: review?(dietrich) → review+
Good point, I reversed the order of unload()/done(), so that unload() gets called first.

Fixed by changeset https://hg.mozilla.org/labs/jetpack-sdk/rev/75c58b70a87e.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
The Add-on SDK is no longer a Mozilla Labs experiment and has become a big enough project to warrant its own Bugzilla product, so the "Add-on SDK" product has been created for it, and I am moving its bugs to that product.

To filter bugmail related to this change, filter on the word "looptid".
Component: Jetpack SDK → General
Product: Mozilla Labs → Add-on SDK
QA Contact: jetpack-sdk → general
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: