From 590bf0abbf6730ec0ffb14e028f391a2950c37cd Mon Sep 17 00:00:00 2001 From: Victor Porof Date: Sun, 3 Jun 2012 20:15:41 +0300 Subject: [PATCH] Bug 759157 - Intermittent browser_tilt_02_notifications.js, browser_tilt_03_tab_switch.js, browser_tilt_04_initialization.js, browser_tilt_picking_miv.js, browser_tilt_picking_highlight01.js | Exited with code 1, timed out after 330 seconds, could not initialize Tilt; r=rcampbell --- browser/devtools/tilt/Tilt.jsm | 12 ++- browser/devtools/tilt/TiltGL.jsm | 12 +-- browser/devtools/tilt/TiltUtils.jsm | 9 +++ .../test/browser_tilt_02_notifications-seq.js | 32 +++++--- .../test/browser_tilt_02_notifications.js | 32 +++++--- .../tilt/test/browser_tilt_03_tab_switch.js | 77 +++++++++++++++++-- .../browser_tilt_04_initialization-key.js | 12 +++ .../test/browser_tilt_04_initialization.js | 14 +++- .../test/browser_tilt_05_destruction-esc.js | 18 ++++- .../test/browser_tilt_05_destruction-url.js | 18 ++++- .../tilt/test/browser_tilt_05_destruction.js | 18 ++++- .../browser_tilt_arcball-reset-typeahead.js | 10 ++- .../tilt/test/browser_tilt_arcball-reset.js | 10 ++- .../tilt/test/browser_tilt_controller.js | 14 +++- .../tilt/test/browser_tilt_picking.js | 9 ++- .../tilt/test/browser_tilt_picking_delete.js | 8 +- .../browser_tilt_picking_highlight01-offs.js | 8 +- .../test/browser_tilt_picking_highlight01.js | 8 +- .../test/browser_tilt_picking_highlight02.js | 8 +- .../test/browser_tilt_picking_highlight03.js | 8 +- .../tilt/test/browser_tilt_picking_miv.js | 10 ++- .../devtools/tilt/test/browser_tilt_zoom.js | 9 ++- browser/devtools/tilt/test/head.js | 48 +++++++++++- 23 files changed, 339 insertions(+), 65 deletions(-) diff --git a/browser/devtools/tilt/Tilt.jsm b/browser/devtools/tilt/Tilt.jsm index c646e3c4ea19..64f430adb17f 100644 --- a/browser/devtools/tilt/Tilt.jsm +++ b/browser/devtools/tilt/Tilt.jsm @@ -100,6 +100,7 @@ Tilt.prototype = { // make sure the visualizer object was initialized properly if (!this.visualizers[id].isInitialized()) { this.destroy(id); + this.failureCallback && this.failureCallback(); return; } @@ -260,14 +261,14 @@ Tilt.prototype = { let onOpened = function() { if (this.inspector && this.highlighter && this.currentInstance) { this.inspector.stopInspecting(); - this.inspector.inspectToolbutton.disabled = true; + this.inspectButton.disabled = true; this.highlighter.hide(); } }.bind(this); let onClosed = function() { if (this.inspector && this.highlighter) { - this.inspector.inspectToolbutton.disabled = false; + this.inspectButton.disabled = false; this.highlighter.show(); } }.bind(this); @@ -333,5 +334,12 @@ Tilt.prototype = { get tiltButton() { return this.chromeWindow.document.getElementById("inspector-3D-button"); + }, + + /** + * Gets the Inspect button in the Inspector toolbar. + */ + get inspectButton() { + return this.chromeWindow.document.getElementById("inspector-inspect-toolbutton"); } }; diff --git a/browser/devtools/tilt/TiltGL.jsm b/browser/devtools/tilt/TiltGL.jsm index 43530820c001..76563983ed8c 100644 --- a/browser/devtools/tilt/TiltGL.jsm +++ b/browser/devtools/tilt/TiltGL.jsm @@ -1554,10 +1554,10 @@ TiltGL.isWebGLSupported = function TGL_isWebGLSupported() supported = gfxInfo.getFeatureStatus(angle) === gfxInfo.FEATURE_NO_INFO || gfxInfo.getFeatureStatus(opengl) === gfxInfo.FEATURE_NO_INFO; } catch(e) { - TiltUtils.Output.error(e.message); - } finally { - return supported; + if (e && e.message) { TiltUtils.Output.error(e.message); } + return false; } + return supported; }; /** @@ -1580,10 +1580,10 @@ TiltGL.create3DContext = function TGL_create3DContext(aCanvas, aFlags) try { context = aCanvas.getContext(WEBGL_CONTEXT_NAME, aFlags); } catch(e) { - TiltUtils.Output.error(e.message); - } finally { - return context; + if (e && e.message) { TiltUtils.Output.error(e.message); } + return null; } + return context; }; /** diff --git a/browser/devtools/tilt/TiltUtils.jsm b/browser/devtools/tilt/TiltUtils.jsm index 12314a9daf1c..ff8898af1f98 100644 --- a/browser/devtools/tilt/TiltUtils.jsm +++ b/browser/devtools/tilt/TiltUtils.jsm @@ -33,6 +33,9 @@ TiltUtils.Output = { */ log: function TUO_log(aMessage) { + if (this.suppressLogs) { + return; + } // get the console service let consoleService = Cc["@mozilla.org/consoleservice;1"] .getService(Ci.nsIConsoleService); @@ -51,6 +54,9 @@ TiltUtils.Output = { */ error: function TUO_error(aMessage, aProperties) { + if (this.suppressErrors) { + return; + } // make sure the properties parameter is a valid object aProperties = aProperties || {}; @@ -85,6 +91,9 @@ TiltUtils.Output = { */ alert: function TUO_alert(aTitle, aMessage) { + if (this.suppressAlerts) { + return; + } if (!aMessage) { aMessage = aTitle; aTitle = ""; diff --git a/browser/devtools/tilt/test/browser_tilt_02_notifications-seq.js b/browser/devtools/tilt/test/browser_tilt_02_notifications-seq.js index 056de7186414..78a6e114fae6 100644 --- a/browser/devtools/tilt/test/browser_tilt_02_notifications-seq.js +++ b/browser/devtools/tilt/test/browser_tilt_02_notifications-seq.js @@ -18,8 +18,7 @@ function test() { waitForExplicitFinish(); createTab(function() { - Services.obs.addObserver(cleanup, DESTROYED, false); - + Services.obs.addObserver(finalize, DESTROYED, false); Services.obs.addObserver(obs_INITIALIZING, INITIALIZING, false); Services.obs.addObserver(obs_INITIALIZED, INITIALIZED, false); Services.obs.addObserver(obs_DESTROYING, DESTROYING, false); @@ -27,7 +26,11 @@ function test() { Services.obs.addObserver(obs_DESTROYED, DESTROYED, false); info("Starting up the Tilt notifications test."); - createTilt({}); + createTilt({}, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); + }); }); } @@ -58,19 +61,26 @@ function obs_DESTROYED() { tabEvents += "DESTROYED;"; } -function cleanup() { - info("Cleaning up the notifications test."); +function finalize() { + if (!tabEvents) { + return; + } is(tabEvents, "INITIALIZING;INITIALIZED;DESTROYING;BEFORE_DESTROYED;DESTROYED;", "The notifications weren't fired in the correct order."); - Services.obs.removeObserver(cleanup, DESTROYED); + cleanup(); +} - Services.obs.removeObserver(obs_INITIALIZING, INITIALIZING, false); - Services.obs.removeObserver(obs_INITIALIZED, INITIALIZED, false); - Services.obs.removeObserver(obs_DESTROYING, DESTROYING, false); - Services.obs.removeObserver(obs_BEFORE_DESTROYED, BEFORE_DESTROYED, false); - Services.obs.removeObserver(obs_DESTROYED, DESTROYED, false); +function cleanup() { + info("Cleaning up the notifications test."); + + Services.obs.removeObserver(finalize, DESTROYED); + Services.obs.removeObserver(obs_INITIALIZING, INITIALIZING); + Services.obs.removeObserver(obs_INITIALIZED, INITIALIZED); + Services.obs.removeObserver(obs_DESTROYING, DESTROYING); + Services.obs.removeObserver(obs_BEFORE_DESTROYED, BEFORE_DESTROYED); + Services.obs.removeObserver(obs_DESTROYED, DESTROYED); gBrowser.removeCurrentTab(); finish(); diff --git a/browser/devtools/tilt/test/browser_tilt_02_notifications.js b/browser/devtools/tilt/test/browser_tilt_02_notifications.js index 2379fda4d506..37623a4eeddf 100644 --- a/browser/devtools/tilt/test/browser_tilt_02_notifications.js +++ b/browser/devtools/tilt/test/browser_tilt_02_notifications.js @@ -27,8 +27,7 @@ function createNewTab() { tab0 = gBrowser.selectedTab; tab1 = createTab(function() { - Services.obs.addObserver(cleanup, DESTROYED, false); - + Services.obs.addObserver(finalize, DESTROYED, false); Services.obs.addObserver(tab_INITIALIZING, INITIALIZING, false); Services.obs.addObserver(tab_DESTROYING, DESTROYING, false); Services.obs.addObserver(tab_SHOWN, SHOWN, false); @@ -41,6 +40,10 @@ function createNewTab() { testStep = 0; tabSelect(); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -80,23 +83,30 @@ let testSteps = [ } ]; -function cleanup() { - info("Cleaning up the notifications test."); +function finalize() { + if (!tabEvents) { + return; + } is(tabEvents, "INITIALIZING;HIDDEN;SHOWN;DESTROYING;", "The notifications weren't fired in the correct order."); + cleanup(); +} + +function cleanup() { + info("Cleaning up the notifications test."); + tab0 = null; tab1 = null; - Services.obs.removeObserver(cleanup, DESTROYED); + Services.obs.removeObserver(finalize, DESTROYED); + Services.obs.removeObserver(tab_INITIALIZING, INITIALIZING); + Services.obs.removeObserver(tab_DESTROYING, DESTROYING); + Services.obs.removeObserver(tab_SHOWN, SHOWN); + Services.obs.removeObserver(tab_HIDDEN, HIDDEN); - Services.obs.removeObserver(tab_INITIALIZING, INITIALIZING, false); - Services.obs.removeObserver(tab_DESTROYING, DESTROYING, false); - Services.obs.removeObserver(tab_SHOWN, SHOWN, false); - Services.obs.removeObserver(tab_HIDDEN, HIDDEN, false); - - gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false); + gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect); gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_03_tab_switch.js b/browser/devtools/tilt/test/browser_tilt_03_tab_switch.js index 16ecd2bb86dd..62b599328b93 100644 --- a/browser/devtools/tilt/test/browser_tilt_03_tab_switch.js +++ b/browser/devtools/tilt/test/browser_tilt_03_tab_switch.js @@ -30,11 +30,24 @@ function createTab1() { { ok(Tilt.tiltButton.checked === false, "The toolbar tilt button shouldn't be pressed before Tilt is open."); + ok(InspectorUI.inspecting, + "The Inspector should be inspecting for tab1."); + ok(InspectorUI.highlighter.hidden === false, + "The Highlighter should be visible for tab1."); }, onTiltOpen: function() { + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting for tab1 after Tilt is open."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should not be visible for tab1 after Tilt is open."); + createTab2(); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -47,12 +60,25 @@ function createTab2() { { ok(Tilt.tiltButton.checked === false, "The toolbar tilt button shouldn't be pressed before Tilt is open."); + ok(InspectorUI.inspecting, + "The Inspector should be inspecting for tab2."); + ok(InspectorUI.highlighter.hidden === false, + "The Highlighter should be visible for tab2."); }, onTiltOpen: function() { + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting for tab2 after Tilt is open."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should be visible for tab2 after Tilt is open."); + testStep = 0; tabSelect(); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -61,53 +87,94 @@ let testSteps = [ function step0() { ok(Tilt.tiltButton.checked === true, "The toolbar tilt button should have been pressed at step0 (tab 2)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step0."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should be hidden at step0."); gBrowser.selectedTab = tab1; }, function step1() { ok(Tilt.tiltButton.checked === true, "The toolbar tilt button should have been pressed at step1 (tab 1)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step1."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should be hidden at step1."); gBrowser.selectedTab = tab0; }, function step2() { ok(Tilt.tiltButton.checked === false, "The toolbar tilt button shouldn't have been pressed at step2 (tab 0)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step2."); + is(InspectorUI.highlighter, null, + "The Highlighter should be dead while in step2."); gBrowser.selectedTab = tab1; }, function step3() { ok(Tilt.tiltButton.checked === true, "The toolbar tilt button should have been pressed at step3 (tab 1)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step3."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should be hidden at step3."); gBrowser.selectedTab = tab2; }, function step4() { ok(Tilt.tiltButton.checked === true, "The toolbar tilt button should have been pressed at step4 (tab 2)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step4."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should be hidden at step4."); Tilt.destroy(Tilt.currentWindowId); gBrowser.removeCurrentTab(); + tab2 = null; }, function step5() { ok(Tilt.tiltButton.checked === true, "The toolbar tilt button should have been pressed at step5 (tab 1)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step5."); + ok(InspectorUI.highlighter.hidden, + "The Highlighter should be hidden at step5."); Tilt.destroy(Tilt.currentWindowId); gBrowser.removeCurrentTab(); + tab1 = null; }, function step6_cleanup() { ok(Tilt.tiltButton.checked === false, "The toolbar tilt button shouldn't have been pressed at step6 (tab 0)."); + ok(InspectorUI.inspecting === false, + "The Inspector should not be inspecting at step6."); + is(InspectorUI.highlighter, null, + "The Highlighter should be dead while in step6."); - tab1 = null; - tab2 = null; - - gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false); - finish(); + cleanup(); } ]; +function cleanup() { + gBrowser.tabContainer.removeEventListener("TabSelect", tabSelect, false); + + if (tab1) { + gBrowser.removeTab(tab1); + tab1 = null; + } + if (tab2) { + gBrowser.removeTab(tab2); + tab2 = null; + } + + finish(); +} + function tabSelect() { if (testStep !== -1) { executeSoon(testSteps[testStep]); diff --git a/browser/devtools/tilt/test/browser_tilt_04_initialization-key.js b/browser/devtools/tilt/test/browser_tilt_04_initialization-key.js index e59692e71267..0acd791dfd31 100644 --- a/browser/devtools/tilt/test/browser_tilt_04_initialization-key.js +++ b/browser/devtools/tilt/test/browser_tilt_04_initialization-key.js @@ -31,6 +31,11 @@ function test() { InspectorUI.toggleInspectorUI(); } +function suddenDeath() { + Services.obs.removeObserver(onTiltOpen, INITIALIZING); + cleanup(); +} + function onInspectorOpen() { Services.obs.removeObserver(onInspectorOpen, INSPECTOR_OPENED); @@ -40,6 +45,8 @@ function onInspectorOpen() { info("Pressing the accesskey should open Tilt."); + Tilt.failureCallback = suddenDeath; + Services.obs.addObserver(onTiltOpen, INITIALIZING, false); EventUtils.synthesizeKey(tiltKey, eventType); }); @@ -65,6 +72,11 @@ function onTiltClose() { is(Tilt.visualizers[id], null, "The current instance of the visualizer wasn't destroyed properly."); + cleanup(); +} + +function cleanup() { + Tilt.failureCallback = null; InspectorUI.closeInspectorUI(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_04_initialization.js b/browser/devtools/tilt/test/browser_tilt_04_initialization.js index 0ca3bef931b3..b4f34869c3da 100644 --- a/browser/devtools/tilt/test/browser_tilt_04_initialization.js +++ b/browser/devtools/tilt/test/browser_tilt_04_initialization.js @@ -45,9 +45,17 @@ function test() { }, onEnd: function() { - gBrowser.removeCurrentTab(); - finish(); + cleanup(); } - }, true); + }, true, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); + }); }); } + +function cleanup() { + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/browser/devtools/tilt/test/browser_tilt_05_destruction-esc.js b/browser/devtools/tilt/test/browser_tilt_05_destruction-esc.js index ca41d5da0db0..c3e1fbfb563a 100644 --- a/browser/devtools/tilt/test/browser_tilt_05_destruction-esc.js +++ b/browser/devtools/tilt/test/browser_tilt_05_destruction-esc.js @@ -2,6 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let tiltOpened = false; + function test() { if (!isTiltEnabled()) { info("Skipping destruction test because Tilt isn't enabled."); @@ -18,14 +20,20 @@ function test() { createTilt({ onTiltOpen: function() { - Services.obs.addObserver(cleanup, DESTROYED, false); + tiltOpened = true; + + Services.obs.addObserver(finalize, DESTROYED, false); EventUtils.sendKey("ESCAPE"); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } -function cleanup() { +function finalize() { let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); is(Tilt.visualizers[id], null, @@ -34,7 +42,11 @@ function cleanup() { ok(InspectorUI.highlighter && InspectorUI.breadcrumbs, "The Inspector should not close while Tilt is opened."); - Services.obs.removeObserver(cleanup, DESTROYED); + cleanup(); +} + +function cleanup() { + if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_05_destruction-url.js b/browser/devtools/tilt/test/browser_tilt_05_destruction-url.js index 4656977baf87..61d428218f1b 100644 --- a/browser/devtools/tilt/test/browser_tilt_05_destruction-url.js +++ b/browser/devtools/tilt/test/browser_tilt_05_destruction-url.js @@ -2,6 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let tiltOpened = false; + function test() { if (!isTiltEnabled()) { info("Skipping destruction test because Tilt isn't enabled."); @@ -18,20 +20,30 @@ function test() { createTilt({ onTiltOpen: function() { - Services.obs.addObserver(cleanup, DESTROYED, false); + tiltOpened = true; + + Services.obs.addObserver(finalize, DESTROYED, false); window.content.location = "about:mozilla"; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } -function cleanup() { +function finalize() { let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); is(Tilt.visualizers[id], null, "The current instance of the visualizer wasn't destroyed properly."); - Services.obs.removeObserver(cleanup, DESTROYED); + cleanup(); +} + +function cleanup() { + if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_05_destruction.js b/browser/devtools/tilt/test/browser_tilt_05_destruction.js index 3e181e75dac5..0f78eb3aaa0e 100644 --- a/browser/devtools/tilt/test/browser_tilt_05_destruction.js +++ b/browser/devtools/tilt/test/browser_tilt_05_destruction.js @@ -2,6 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let tiltOpened = false; + function test() { if (!isTiltEnabled()) { info("Skipping destruction test because Tilt isn't enabled."); @@ -18,20 +20,30 @@ function test() { createTilt({ onTiltOpen: function() { - Services.obs.addObserver(cleanup, DESTROYED, false); + tiltOpened = true; + + Services.obs.addObserver(finalize, DESTROYED, false); InspectorUI.closeInspectorUI(); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } -function cleanup() { +function finalize() { let id = TiltUtils.getWindowId(gBrowser.selectedBrowser.contentWindow); is(Tilt.visualizers[id], null, "The current instance of the visualizer wasn't destroyed properly."); - Services.obs.removeObserver(cleanup, DESTROYED); + cleanup(); +} + +function cleanup() { + if (tiltOpened) { Services.obs.removeObserver(finalize, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_arcball-reset-typeahead.js b/browser/devtools/tilt/test/browser_tilt_arcball-reset-typeahead.js index 2cb99eb0624e..f70223be9395 100644 --- a/browser/devtools/tilt/test/browser_tilt_arcball-reset-typeahead.js +++ b/browser/devtools/tilt/test/browser_tilt_arcball-reset-typeahead.js @@ -2,6 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let tiltOpened = false; + function test() { if (!isTiltEnabled()) { info("Skipping part of the arcball test because Tilt isn't enabled."); @@ -20,6 +22,8 @@ function test() { createTilt({ onTiltOpen: function(instance) { + tiltOpened = true; + performTest(instance.presenter.canvas, instance.controller.arcball, function() { @@ -30,6 +34,10 @@ function test() { InspectorUI.closeInspectorUI(); }); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -117,7 +125,7 @@ function performTest(canvas, arcball, callback) { function cleanup() { info("Cleaning up arcball reset test."); - Services.obs.removeObserver(cleanup, DESTROYED); + if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_arcball-reset.js b/browser/devtools/tilt/test/browser_tilt_arcball-reset.js index 42a0ac2de75a..4d64d9be8de6 100644 --- a/browser/devtools/tilt/test/browser_tilt_arcball-reset.js +++ b/browser/devtools/tilt/test/browser_tilt_arcball-reset.js @@ -2,6 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let tiltOpened = false; + function test() { if (!isTiltEnabled()) { info("Skipping part of the arcball test because Tilt isn't enabled."); @@ -19,6 +21,8 @@ function test() { createTilt({ onTiltOpen: function(instance) { + tiltOpened = true; + performTest(instance.presenter.canvas, instance.controller.arcball, function() { @@ -28,6 +32,10 @@ function test() { InspectorUI.closeInspectorUI(); }); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -115,7 +123,7 @@ function performTest(canvas, arcball, callback) { function cleanup() { info("Cleaning up arcball reset test."); - Services.obs.removeObserver(cleanup, DESTROYED); + if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_controller.js b/browser/devtools/tilt/test/browser_tilt_controller.js index 45bf84db0577..0dbf37aadeeb 100644 --- a/browser/devtools/tilt/test/browser_tilt_controller.js +++ b/browser/devtools/tilt/test/browser_tilt_controller.js @@ -118,9 +118,17 @@ function test() { }, onEnd: function() { - gBrowser.removeCurrentTab(); - finish(); + cleanup(); } - }, true); + }, true, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); + }); }); } + +function cleanup() { + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/browser/devtools/tilt/test/browser_tilt_picking.js b/browser/devtools/tilt/test/browser_tilt_picking.js index 48a8b04d7ecc..ba7a0b968e7a 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking.js +++ b/browser/devtools/tilt/test/browser_tilt_picking.js @@ -2,6 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let pickDone = false; + function test() { if (!isTiltEnabled()) { info("Skipping picking test because Tilt isn't enabled."); @@ -30,18 +32,23 @@ function test() { ok(data.index > 0, "Simply picking a node didn't work properly."); + pickDone = true; Services.obs.addObserver(cleanup, DESTROYED, false); InspectorUI.closeInspectorUI(); } }); }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (pickDone) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_picking_delete.js b/browser/devtools/tilt/test/browser_tilt_picking_delete.js index dff13ddd6c16..95e6b7c69339 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_delete.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_delete.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let nodeDeleted = false; let presenter; function test() { @@ -34,11 +35,16 @@ function test() { ok(!presenter._highlight.disabled, "After highlighting a node, it should be highlighted. D'oh."); + nodeDeleted = true; presenter.deleteNode(); } }); }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -64,7 +70,7 @@ function whenNodeRemoved() { } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (nodeDeleted) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_picking_highlight01-offs.js b/browser/devtools/tilt/test/browser_tilt_picking_highlight01-offs.js index ca87ecec616b..4c3624d90a1d 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_highlight01-offs.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight01-offs.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let nodeHighlighted = false; let presenter; function test() { @@ -27,9 +28,14 @@ function test() { let contentDocument = presenter.contentWindow.document; let div = contentDocument.getElementById("far-far-away"); + nodeHighlighted = true; presenter.highlightNode(div, "moveIntoView"); }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -63,7 +69,7 @@ function whenUnhighlighting() { } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_picking_highlight01.js b/browser/devtools/tilt/test/browser_tilt_picking_highlight01.js index d70278e8896c..b498d2ac07c6 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_highlight01.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight01.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let nodeHighlighted = false; let presenter; function test() { @@ -27,9 +28,14 @@ function test() { let contentDocument = presenter.contentWindow.document; let div = contentDocument.getElementById("first-law"); + nodeHighlighted = true; presenter.highlightNode(div, "moveIntoView"); }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -63,7 +69,7 @@ function whenUnhighlighting() { } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_picking_highlight02.js b/browser/devtools/tilt/test/browser_tilt_picking_highlight02.js index bc24adbd39bf..9d873d1ea181 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_highlight02.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight02.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let nodeHighlighted = false; let presenter; function test() { @@ -24,9 +25,14 @@ function test() { Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false); presenter._onInitializationFinished = function() { + nodeHighlighted = true; presenter.highlightNodeAt.apply(this, getPickablePoint(presenter)); }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -58,7 +64,7 @@ function whenUnhighlighting() { } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js b/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js index b52b767ada41..0412b76b586e 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let nodeHighlighted = false; let presenter; function test() { @@ -24,9 +25,14 @@ function test() { Services.obs.addObserver(whenHighlighting, HIGHLIGHTING, false); presenter._onInitializationFinished = function() { + nodeHighlighted = true; presenter.highlightNodeFor(3); // 1 = html, 2 = body, 3 = first div }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -58,7 +64,7 @@ function whenUnhighlighting() { } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_picking_miv.js b/browser/devtools/tilt/test/browser_tilt_picking_miv.js index 3c9cbc1fdde9..ebac1272174d 100644 --- a/browser/devtools/tilt/test/browser_tilt_picking_miv.js +++ b/browser/devtools/tilt/test/browser_tilt_picking_miv.js @@ -2,6 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +let nodeHighlighted = false; let presenter; function test() { @@ -27,9 +28,14 @@ function test() { let contentDocument = presenter.contentWindow.document; let div = contentDocument.getElementById("far-far-away"); + nodeHighlighted = true; presenter.highlightNode(div); }; } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } @@ -57,14 +63,14 @@ function whenBringingIntoView() { "when this is being explicitly requested!"); executeSoon(function() { + Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING); Services.obs.addObserver(cleanup, DESTROYED, false); InspectorUI.closeInspectorUI(); }); } function cleanup() { - Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING); - Services.obs.removeObserver(cleanup, DESTROYED); + if (nodeHighlighted) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/browser_tilt_zoom.js b/browser/devtools/tilt/test/browser_tilt_zoom.js index fe280dfba3b0..104bd113a05a 100644 --- a/browser/devtools/tilt/test/browser_tilt_zoom.js +++ b/browser/devtools/tilt/test/browser_tilt_zoom.js @@ -4,6 +4,7 @@ const ZOOM = 2; const RESIZE = 50; +let tiltOpened = false; function test() { if (!isTiltEnabled()) { @@ -25,6 +26,8 @@ function test() { }, onTiltOpen: function(instance) { + tiltOpened = true; + ok(isApprox(InspectorUI.highlighter.zoom, ZOOM), "The Highlighter zoom doesn't have the expected results."); @@ -75,12 +78,16 @@ function test() { InspectorUI.closeInspectorUI(); }); } + }, false, function suddenDeath() + { + info("Tilt could not be initialized properly."); + cleanup(); }); }); } function cleanup() { - Services.obs.removeObserver(cleanup, DESTROYED); + if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); } gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/tilt/test/head.js b/browser/devtools/tilt/test/head.js index fe18f8143268..613831c91627 100644 --- a/browser/devtools/tilt/test/head.js +++ b/browser/devtools/tilt/test/head.js @@ -65,11 +65,19 @@ const INSP_ENABLED = Services.prefs.getBoolPref("devtools.inspector.enabled"); function isTiltEnabled() { - return TILT_ENABLED && INSP_ENABLED; + let enabled = TILT_ENABLED && INSP_ENABLED; + + info("Apparently, Tilt is" + (enabled ? "" : " not") + " enabled."); + return enabled; } function isWebGLSupported() { - return TiltGL.isWebGLSupported() && TiltGL.create3DContext(createCanvas()); + let supported = !TiltGL.isWebGLForceEnabled() && + TiltGL.isWebGLSupported() && + TiltGL.create3DContext(createCanvas()); + + info("Apparently, WebGL is" + (supported ? "" : " not") + " supported."); + return supported; } function isApprox(num1, num2, delta) { @@ -118,6 +126,9 @@ function createCanvas() { function createTab(callback, location) { + info("Creating a tab, with callback " + typeof callback + + ", and location " + location + "."); + let tab = gBrowser.selectedTab = gBrowser.addTab(); gBrowser.selectedBrowser.addEventListener("load", function onLoad() { @@ -130,35 +141,48 @@ function createTab(callback, location) { } -function createTilt(callbacks, close) { - Services.prefs.setBoolPref("webgl.verbose", true); +function createTilt(callbacks, close, suddenDeath) { + info("Creating Tilt, with callbacks {" + Object.keys(callbacks) + "}" + + ", autoclose param " + close + + ", and sudden death handler " + typeof suddenDeath + "."); + Services.prefs.setBoolPref("webgl.verbose", true); + TiltUtils.Output.suppressAlerts = true; + + info("Attempting to start the inspector."); Services.obs.addObserver(onInspectorOpen, INSPECTOR_OPENED, false); InspectorUI.toggleInspectorUI(); function onInspectorOpen() { + info("Inspector was opened."); Services.obs.removeObserver(onInspectorOpen, INSPECTOR_OPENED); executeSoon(function() { if ("function" === typeof callbacks.onInspectorOpen) { + info("Calling 'onInspectorOpen'."); callbacks.onInspectorOpen(); } executeSoon(function() { + info("Attempting to start Tilt."); Services.obs.addObserver(onTiltOpen, INITIALIZING, false); + handleFailure(suddenDeath); Tilt.initialize(); }); }); } function onTiltOpen() { + info("Tilt was opened."); Services.obs.removeObserver(onTiltOpen, INITIALIZING); executeSoon(function() { if ("function" === typeof callbacks.onTiltOpen) { + info("Calling 'onTiltOpen'."); callbacks.onTiltOpen(Tilt.visualizers[Tilt.currentWindowId]); } if (close) { executeSoon(function() { + info("Attempting to close Tilt."); Services.obs.addObserver(onTiltClose, DESTROYED, false); Tilt.destroy(Tilt.currentWindowId); }); @@ -167,14 +191,17 @@ function createTilt(callbacks, close) { } function onTiltClose() { + info("Tilt was closed."); Services.obs.removeObserver(onTiltClose, DESTROYED); executeSoon(function() { if ("function" === typeof callbacks.onTiltClose) { + info("Calling 'onTiltClose'."); callbacks.onTiltClose(); } if (close) { executeSoon(function() { + info("Attempting to close the Inspector."); Services.obs.addObserver(onInspectorClose, INSPECTOR_CLOSED, false); InspectorUI.closeInspectorUI(); }); @@ -183,17 +210,30 @@ function createTilt(callbacks, close) { } function onInspectorClose() { + info("Inspector was closed."); Services.obs.removeObserver(onInspectorClose, INSPECTOR_CLOSED); executeSoon(function() { if ("function" === typeof callbacks.onInspectorClose) { + info("Calling 'onInspectorClose'."); callbacks.onInspectorClose(); } if ("function" === typeof callbacks.onEnd) { + info("Calling 'onEnd'."); callbacks.onEnd(); } }); } + + function handleFailure(suddenDeath) { + Tilt.failureCallback = function() { + info("Tilt FAIL."); + Services.obs.removeObserver(onTiltOpen, INITIALIZING); + + info("Now relying on sudden death handler " + typeof suddenDeath + "."); + suddenDeath && suddenDeath(); + } + } } function getPickablePoint(presenter) {