mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
220 lines
4.5 KiB
HTML
220 lines
4.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf8">
|
|
<title>Test for JavaScript terminal functionality</title>
|
|
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript;version=1.8" src="common.js"></script>
|
|
<!-- Any copyright is dedicated to the Public Domain.
|
|
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
|
</head>
|
|
<body>
|
|
<p>Test for JavaScript terminal functionality</p>
|
|
|
|
<script class="testbody" type="text/javascript;version=1.8">
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
let gState;
|
|
|
|
function startTest()
|
|
{
|
|
removeEventListener("load", startTest);
|
|
|
|
attachConsole(["PageError"], onAttach, true);
|
|
}
|
|
|
|
function onAttach(aState, aResponse)
|
|
{
|
|
top.foobarObject = Object.create(null);
|
|
top.foobarObject.foo = 1;
|
|
top.foobarObject.foobar = 2;
|
|
top.foobarObject.foobaz = 3;
|
|
top.foobarObject.omg = 4;
|
|
top.foobarObject.omgfoo = 5;
|
|
top.foobarObject.strfoo = "foobarz";
|
|
top.foobarObject.omgstr = "foobarz" +
|
|
(new Array(DebuggerServer.LONG_STRING_LENGTH * 2)).join("abb");
|
|
|
|
gState = aState;
|
|
|
|
let tests = [doAutocomplete1, doAutocomplete2, doSimpleEval, doWindowEval,
|
|
doEvalWithException, doEvalWithHelper, doEvalString, doEvalLongString];
|
|
runTests(tests, testEnd);
|
|
}
|
|
|
|
function doAutocomplete1()
|
|
{
|
|
info("test autocomplete for 'window.foo'");
|
|
gState.client.autocomplete("window.foo", 0, onAutocomplete1);
|
|
}
|
|
|
|
function onAutocomplete1(aResponse)
|
|
{
|
|
let matches = aResponse.matches;
|
|
|
|
is(aResponse.matchProp, "foo", "matchProp");
|
|
is(matches.length, 1, "matches.length");
|
|
is(matches[0], "foobarObject", "matches[0]");
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doAutocomplete2()
|
|
{
|
|
info("test autocomplete for 'window.foobarObject.'");
|
|
gState.client.autocomplete("window.foobarObject.", 0, onAutocomplete2);
|
|
}
|
|
|
|
function onAutocomplete2(aResponse)
|
|
{
|
|
let matches = aResponse.matches;
|
|
|
|
ok(!aResponse.matchProp, "matchProp");
|
|
is(matches.length, 7, "matches.length");
|
|
checkObject(matches,
|
|
["foo", "foobar", "foobaz", "omg", "omgfoo", "omgstr", "strfoo"]);
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doSimpleEval()
|
|
{
|
|
info("test eval '2+2'");
|
|
gState.client.evaluateJS("2+2", onSimpleEval);
|
|
}
|
|
|
|
function onSimpleEval(aResponse)
|
|
{
|
|
checkObject(aResponse, {
|
|
from: gState.actor,
|
|
input: "2+2",
|
|
result: 4,
|
|
});
|
|
|
|
ok(!aResponse.error, "no js error");
|
|
ok(!aResponse.helperResult, "no helper result");
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doWindowEval()
|
|
{
|
|
info("test eval 'window'");
|
|
gState.client.evaluateJS("window", onWindowEval);
|
|
}
|
|
|
|
function onWindowEval(aResponse)
|
|
{
|
|
checkObject(aResponse, {
|
|
from: gState.actor,
|
|
input: "window",
|
|
result: {
|
|
type: "object",
|
|
className: "Window",
|
|
actor: /[a-z]/,
|
|
},
|
|
});
|
|
|
|
ok(!aResponse.error, "no js error");
|
|
ok(!aResponse.helperResult, "no helper result");
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doEvalWithException()
|
|
{
|
|
info("test eval with exception");
|
|
gState.client.evaluateJS("window.doTheImpossible()", onEvalWithException);
|
|
}
|
|
|
|
function onEvalWithException(aResponse)
|
|
{
|
|
checkObject(aResponse, {
|
|
from: gState.actor,
|
|
input: "window.doTheImpossible()",
|
|
result: {
|
|
type: "undefined",
|
|
},
|
|
errorMessage: /doTheImpossible/,
|
|
});
|
|
|
|
ok(aResponse.error, "js error object");
|
|
ok(!aResponse.helperResult, "no helper result");
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doEvalWithHelper()
|
|
{
|
|
info("test eval with helper");
|
|
gState.client.evaluateJS("clear()", onEvalWithHelper);
|
|
}
|
|
|
|
function onEvalWithHelper(aResponse)
|
|
{
|
|
checkObject(aResponse, {
|
|
from: gState.actor,
|
|
input: "clear()",
|
|
result: {
|
|
type: "undefined",
|
|
},
|
|
helperResult: { type: "clearOutput" },
|
|
});
|
|
|
|
ok(!aResponse.error, "no js error");
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doEvalString()
|
|
{
|
|
gState.client.evaluateJS("window.foobarObject.strfoo", onEvalString);
|
|
}
|
|
|
|
function onEvalString(aResponse)
|
|
{
|
|
checkObject(aResponse, {
|
|
from: gState.actor,
|
|
input: "window.foobarObject.strfoo",
|
|
result: "foobarz",
|
|
});
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function doEvalLongString()
|
|
{
|
|
gState.client.evaluateJS("window.foobarObject.omgstr", onEvalLongString);
|
|
}
|
|
|
|
function onEvalLongString(aResponse)
|
|
{
|
|
let str = top.foobarObject.omgstr;
|
|
let initial = str.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
|
|
|
|
checkObject(aResponse, {
|
|
from: gState.actor,
|
|
input: "window.foobarObject.omgstr",
|
|
result: {
|
|
type: "longString",
|
|
initial: initial,
|
|
length: str.length,
|
|
},
|
|
});
|
|
|
|
nextTest();
|
|
}
|
|
|
|
function testEnd()
|
|
{
|
|
closeDebugger(gState, function() {
|
|
gState = null;
|
|
SimpleTest.finish();
|
|
});
|
|
}
|
|
|
|
addEventListener("load", startTest);
|
|
</script>
|
|
</body>
|
|
</html>
|