diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/debugger/test/mochitest/browser_dbg_progress-listener-bug.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg_progress-listener-bug.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg_progress-listener-bug.js | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_progress-listener-bug.js b/devtools/client/debugger/test/mochitest/browser_dbg_progress-listener-bug.js new file mode 100644 index 000000000..e5aac615a --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_progress-listener-bug.js @@ -0,0 +1,89 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Tests that the debugger does show up even if a progress listener reads the + * WebProgress argument's DOMWindow property in onStateChange() (bug 771655). + */ + +var gTab, gPanel, gDebugger; +var gOldListener; + +const TAB_URL = EXAMPLE_URL + "doc_inline-script.html"; + +function test() { + installListener(); + + let options = { + source: TAB_URL, + line: 1 + }; + initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => { + gTab = aTab; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + + is(!!gDebugger.DebuggerController._startup, true, + "Controller should be initialized after starting the test."); + + testPause(); + }); +} + +function testPause() { + let onCaretUpdated = waitForCaretUpdated(gPanel, 16); + callInTab(gTab, "runDebuggerStatement"); + onCaretUpdated.then(() => { + is(gDebugger.gThreadClient.state, "paused", + "The debugger statement was reached."); + + resumeDebuggerThenCloseAndFinish(gPanel); + }); +} + +// This is taken almost verbatim from bug 771655. +function installListener() { + if ("_testPL" in window) { + gOldListener = _testPL; + + Cc["@mozilla.org/docloaderservice;1"] + .getService(Ci.nsIWebProgress) + .removeProgressListener(_testPL); + } + + window._testPL = { + START_DOC: Ci.nsIWebProgressListener.STATE_START | + Ci.nsIWebProgressListener.STATE_IS_DOCUMENT, + onStateChange: function (wp, req, stateFlags, status) { + if ((stateFlags & this.START_DOC) === this.START_DOC) { + // This DOMWindow access triggers the unload event. + wp.DOMWindow; + } + }, + QueryInterface: function (iid) { + if (iid.equals(Ci.nsISupportsWeakReference) || + iid.equals(Ci.nsIWebProgressListener)) + return this; + throw Cr.NS_ERROR_NO_INTERFACE; + } + }; + + Cc["@mozilla.org/docloaderservice;1"] + .getService(Ci.nsIWebProgress) + .addProgressListener(_testPL, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST); +} + +registerCleanupFunction(function () { + if (gOldListener) { + window._testPL = gOldListener; + } else { + delete window._testPL; + } + + gTab = null; + gPanel = null; + gDebugger = null; + gOldListener = null; +}); |