1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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;
});
|