зеркало из https://github.com/mozilla/gecko-dev.git
66 строки
1.9 KiB
HTML
66 строки
1.9 KiB
HTML
<!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>
|