зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1382377 - Test console against devtools.enabled pref. r=baku
MozReview-Commit-ID: GEayP1MP8PV --HG-- extra : rebase_source : 754ff2f10d96939f1c0f578d74a3016db26504f4
This commit is contained in:
Родитель
3675c8a0f9
Коммит
f67740b33e
|
@ -9,3 +9,4 @@ support-files =
|
|||
[test_consoleEmptyStack.html]
|
||||
[test_console_binding.html]
|
||||
[test_console_proto.html]
|
||||
[test_devtools_pref.html]
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test Console with devtools preference</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript">
|
||||
|
||||
function consoleListener(expected) {
|
||||
var messages = [];
|
||||
return new Promise(done => {
|
||||
let observer = {
|
||||
observe: function listener(aSubject, aTopic, aData) {
|
||||
var obj = aSubject.wrappedJSObject;
|
||||
messages.push(parseInt(obj.arguments[0]));
|
||||
if (messages.length == expected) {
|
||||
SpecialPowers.removeObserver(observer, "console-api-log-event");
|
||||
SpecialPowers.removeObserver(observer, "console-api-profiler");
|
||||
done(messages);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
SpecialPowers.addObserver(observer, "console-api-log-event");
|
||||
SpecialPowers.addObserver(observer, "console-api-profiler");
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
(async function () {
|
||||
var onMessages = consoleListener(4);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", false]]});
|
||||
console.log(1);
|
||||
console.profile(2);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", true]]});
|
||||
console.log(3);
|
||||
console.profile(4);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", false]]});
|
||||
console.log(5);
|
||||
console.profile(6);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({set: [["devtools.enabled", true]]});
|
||||
console.log(7);
|
||||
console.profile(8);
|
||||
|
||||
var messages = await onMessages;
|
||||
|
||||
is(messages[0], 3, "Got only console message while pref was true");
|
||||
is(messages[1], 4, "Got only profile message while pref was true");
|
||||
is(messages[2], 7, "Got only console message while pref was true");
|
||||
is(messages[3], 8, "Got only profile message while pref was true");
|
||||
|
||||
SimpleTest.finish();
|
||||
})();
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче