diff options
Diffstat (limited to 'devtools/shared/webconsole/test/chrome/test_commands_other.html')
-rw-r--r-- | devtools/shared/webconsole/test/chrome/test_commands_other.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/devtools/shared/webconsole/test/chrome/test_commands_other.html b/devtools/shared/webconsole/test/chrome/test_commands_other.html new file mode 100644 index 0000000000..702d01f354 --- /dev/null +++ b/devtools/shared/webconsole/test/chrome/test_commands_other.html @@ -0,0 +1,84 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="utf8"> + <title>Test for the other command helpers</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="common.js"></script> + <!-- Any copyright is dedicated to the Public Domain. + - http://creativecommons.org/publicdomain/zero/1.0/ --> +</head> +<body> +<p>Test for the querySelector / querySelectorAll helpers</p> + +<script class="testbody" type="text/javascript"> +"use strict"; + +SimpleTest.waitForExplicitFinish(); +let gState; +let gWin; +const tests = [ + async function keys() { + const response = await evaluateJS("keys({foo: 'bar'})"); + checkObject(response, { + result: { + class: "Array", + preview: { + items: ["foo"] + } + } + }); + nextTest(); + }, + async function values() { + const response = await evaluateJS("values({foo: 'bar'})"); + checkObject(response, { + result: { + class: "Array", + preview: { + items: ["bar"] + } + } + }); + nextTest(); + }, +]; + +function evaluateJS(input) { + return gState.webConsoleFront.evaluateJSAsync(input); +} + +async function startTest() { + info ("Content window opened, attaching console to it"); + + const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal); + ok (!gWin.document.nodePrincipal.equals(systemPrincipal), + "The test document is not using the system principal"); + + const {state} = await attachConsoleToTab([]); + gState = state; + runTests(tests, testEnd); +} + +function testEnd() { + gWin.close(); + gWin = null; + closeDebugger(gState, function() { + gState = null; + SimpleTest.finish(); + }); +} + +const load = async function () { + removeEventListener("load", load); + + // Open a content window to test XRay functionality on built in functions. + gWin = window.open("javascript:'<html><body>dummy</body></html>';"); + info ("Waiting for content window to load"); + gWin.onload = startTest; +}; +addEventListener("load", load); + +</script> +</body> +</html> |