diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/test_domcursor.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_domcursor.html')
-rw-r--r-- | dom/base/test/test_domcursor.html | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/dom/base/test/test_domcursor.html b/dom/base/test/test_domcursor.html new file mode 100644 index 000000000..d33581f12 --- /dev/null +++ b/dom/base/test/test_domcursor.html @@ -0,0 +1,140 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for DOMCursor</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="application/javascript;version=1.7"> +"use strict"; + +SimpleTest.waitForExplicitFinish(); + +var reqserv = SpecialPowers.getDOMRequestService(); +ok("createRequest" in reqserv, "appears to be a service"); + +var req; +var lastContinue = false; + +var index = 0; + +function next() { + if (index < tests.length) { + ok(true, "Begin test"); + tests[index++](); + } else { + ok(true, "All done"); + SimpleTest.finish(); + } +} + +var tests = [ + function() { + // create a cursor, test its interface and its initial state + req = reqserv.createCursor(window, function() { + if (lastContinue) { + reqserv.fireDone(req); + } else { + reqserv.fireSuccess(req, "next result") + } + }); + ok("result" in req, "cursor has result"); + ok("error" in req, "cursor has error"); + ok("onsuccess" in req, "cursor has onsuccess"); + ok("onerror" in req, "cursor has onerror"); + ok("readyState" in req, "cursor has readyState"); + ok("done" in req, "cursor has finished"); + ok("continue" in req, "cursor has continue"); + ok(!("then" in req), "cursor should not have a then method"); + + is(req.readyState, "pending", "readyState is pending"); + is(req.result, undefined, "result is undefined"); + is(req.onsuccess, null, "onsuccess is null"); + is(req.onerror, null, "onerror is null"); + next(); + }, + function() { + // fire success + req.onsuccess = function(e) { + ok(e, "got success event"); + is(e.type, "success", "correct type during success"); + is(e.target, req, "correct target during success"); + is(req.readyState, "done", "correct readyState after success"); + is(req.error, null, "correct error after success"); + is(req.result, "my result", "correct result after success"); + is(req.done, false, "cursor is not done after continue") + next(); + } + reqserv.fireSuccess(req, "my result"); + }, + function() { + // continue + req.onsuccess = function(e) { + ok(e, "got success event after continue"); + is(e.type, "success", "correct type during continue"); + is(e.target, req, "correct target during continue"); + is(req.readyState, "done", "correct readyState after continue"); + is(req.error, null, "correct error after continue"); + is(req.result, "next result", "correct result after continue"); + is(req.done, false, "cursor is not done after continue") + next(); + } + req.continue(); + }, + function() { + // FireDone + req.onsuccess = function(e) { + ok(e, "got success event after continue"); + is(e.type, "success", "correct type during continue"); + is(e.target, req, "correct target during continue"); + is(req.readyState, "done", "correct readyState after continue"); + is(req.error, null, "correct error after continue"); + is(req.result, undefined, "no result after last continue"); + is(req.done, true, "cursor is done after last continue") + try { + req.continue(); + ok(false, "continue when cursor is done should fail"); + } catch (e) { + ok(true, "continue when cursor is done should fail"); + } + + next(); + } + lastContinue = true; + req.continue(); + }, + function() { + // fire error + req = reqserv.createCursor(window, function(){}); + req.onerror = function(e) { + ok(e, "got success event"); + is(e.type, "error", "correct type during error"); + is(e.target, req, "correct target during error"); + is(req.readyState, "done", "correct readyState after error"); + is(req.error.name, "error msg", "correct error after error"); + is(req.result, undefined, "correct result after error"); + try { + req.continue(); + ok(false, "continue while in an error state should fail"); + } catch (e) { + ok(true, "continue while in an error state should fail"); + } + + next(); + } + reqserv.fireError(req, "error msg"); + } +]; + +next(); + +</script> +</pre> +</body> +</html> |