Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix issue 5958 #48

Merged
merged 1 commit into from

2 participants

@fflorent
Owner

Fix for this issue : http://code.google.com/p/fbug/issues/detail?id=5958

I am wondering if the use of MutationObserver is right, since the feature has been introduced in Firefox 14 (and this version of Firebug seems to support Firefox 13 according to install.rdf).

@janodvarko janodvarko merged commit f8ddde0 into from
@janodvarko
Owner

Thanks, it works for me!

Anyway, I think that the following: "timeout = setTimeout(compareAndCallback, 1000);" line is rather a hack.

I am merging anyway, to see what the test bot says...

Honza

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 6, 2012
  1. @fflorent

    Fix issue 5958

    fflorent authored
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 11 deletions.
  1. +23 −11 tests/content/script/watch/5639/issue5639.js
View
34 tests/content/script/watch/5639/issue5639.js
@@ -32,20 +32,32 @@ function testDeleteAllWatches(callback, panelNode, targetSelector, watchExpressi
{
addWatches(watchExpressions.slice(0), function()
{
- FBTest.compare(watchExpressions.length, countWatches(panelNode), "all the watches must be added");
+ FBTest.compare(watchExpressions.length, countWatches(panelNode),
+ "all the watches must be added");
var target = panelNode.querySelector(targetSelector);
- FBTest.executeContextMenuCommand(target, "fbDeleteAllWatches", function()
+
+ var timeout, compareAndCallback, observer;
+ compareAndCallback = function()
{
- // xxxHonza: needs to be done properly.
- // The code should handle a mutation event or periodically check (for
- // limited amount of time) if the watch window is empty.
- // See: http://code.google.com/p/fbug/issues/detail?id=5958
- setTimeout(function()
- {
- FBTest.compare(0, countWatches(panelNode), "There should not be any watch");
- callback();
- }, 1000);
+ FBTest.compare(0, countWatches(panelNode), "There should not be any watch");
+ clearTimeout(timeout);
+ observer.disconnect();
+ callback();
+ };
+ // the timeout is triggered if the MutationObserver has not detected
+ // the deletion of the watch expressions
+ timeout = setTimeout(compareAndCallback, 1000);
+
+ observer = new MutationObserver(function(mutations)
+ {
+ // if there is no watch any more, we run compareAndCallback now
+ // otherwise, we wait for another mutation or for the timeout
+ if (countWatches(panelNode) === 0)
+ compareAndCallback();
});
+ observer.observe(panelNode, {childList: true});
+
+ FBTest.executeContextMenuCommand(target, "fbDeleteAllWatches");
});
}
Something went wrong with that request. Please try again.