зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1133540 - Add Test Coverage for the Assertion. r=khuey
This commit is contained in:
Родитель
37daf2b55c
Коммит
859a0eeab3
|
@ -112,7 +112,14 @@ function testHarnessSteps() {
|
|||
|
||||
let worker = new Worker(workerScriptURL);
|
||||
|
||||
worker._expectingUncaughtException = false;
|
||||
worker.onerror = function(event) {
|
||||
if (worker._expectingUncaughtException) {
|
||||
ok(true, "Worker had an expected error: " + event.message);
|
||||
worker._expectingUncaughtException = false;
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
ok(false, "Worker had an error: " + event.message);
|
||||
worker.terminate();
|
||||
nextTestHarnessStep();
|
||||
|
@ -146,6 +153,10 @@ function testHarnessSteps() {
|
|||
nextTestHarnessStep();
|
||||
break;
|
||||
|
||||
case "expectUncaughtException":
|
||||
worker._expectingUncaughtException = message.expecting;
|
||||
break;
|
||||
|
||||
default:
|
||||
ok(false,
|
||||
"Received a bad message from worker: " + JSON.stringify(message));
|
||||
|
@ -157,6 +168,11 @@ function testHarnessSteps() {
|
|||
|
||||
yield undefined;
|
||||
|
||||
if (worker._expectingUncaughtException) {
|
||||
ok(false, "expectUncaughtException was called but no uncaught " +
|
||||
"exception was detected!");
|
||||
}
|
||||
|
||||
worker.terminate();
|
||||
worker = null;
|
||||
|
||||
|
@ -233,6 +249,11 @@ function errorHandler(event)
|
|||
finishTest();
|
||||
}
|
||||
|
||||
function expectUncaughtException(expecting)
|
||||
{
|
||||
SimpleTest.expectUncaughtException(expecting);
|
||||
}
|
||||
|
||||
function browserErrorHandler(event)
|
||||
{
|
||||
browserFinishTest();
|
||||
|
@ -385,6 +406,10 @@ function workerScript() {
|
|||
};
|
||||
|
||||
self.finishTest = function() {
|
||||
if (self._expectingUncaughtException) {
|
||||
self.ok(false, "expectUncaughtException was called but no uncaught "
|
||||
+ "exception was detected!");
|
||||
}
|
||||
self.postMessage({ op: "done" });
|
||||
};
|
||||
|
||||
|
@ -480,7 +505,19 @@ function workerScript() {
|
|||
return buffer;
|
||||
};
|
||||
|
||||
self._expectingUncaughtException = false;
|
||||
self.expectUncaughtException = function(_expecting_) {
|
||||
self._expectingUncaughtException = !!_expecting_;
|
||||
self.postMessage({ op: "expectUncaughtException", expecting: !!_expecting_ });
|
||||
};
|
||||
|
||||
self.onerror = function(_message_, _file_, _line_) {
|
||||
if (self._expectingUncaughtException) {
|
||||
self._expectingUncaughtException = false;
|
||||
ok(true, "Worker: expected exception [" + _file_ + ":" + _line_ + "]: '" +
|
||||
_message_ + "'");
|
||||
return;
|
||||
}
|
||||
ok(false,
|
||||
"Worker: uncaught exception [" + _file_ + ":" + _line_ + "]: '" +
|
||||
_message_ + "'");
|
||||
|
|
|
@ -92,6 +92,7 @@ support-files =
|
|||
unit/test_setVersion_abort.js
|
||||
unit/test_setVersion_events.js
|
||||
unit/test_setVersion_exclusion.js
|
||||
unit/test_setVersion_throw.js
|
||||
unit/test_success_events_after_abort.js
|
||||
unit/test_table_locks.js
|
||||
unit/test_table_rollback.js
|
||||
|
@ -343,6 +344,8 @@ skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
|
|||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
|
||||
[test_setVersion_exclusion.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
|
||||
[test_setVersion_throw.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
|
||||
[test_success_events_after_abort.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
|
||||
[test_table_locks.html]
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Indexed Database Property Test</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<script type="text/javascript;version=1.7" src="unit/test_setVersion_throw.js"></script>
|
||||
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();"></body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var testGenerator = testSteps();
|
||||
|
||||
function testSteps()
|
||||
{
|
||||
const name = this.window ? window.location.pathname : "test_setVersion_throw";
|
||||
|
||||
// This test requires two databases. The first needs to be a low version
|
||||
// number that gets closed when a second higher version number database is
|
||||
// created. Then the upgradeneeded event for the second database throws an
|
||||
// exception and triggers an abort/close.
|
||||
|
||||
let request = indexedDB.open(name, 1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
request.onupgradeneeded = function(event) {
|
||||
info("Got upgradeneeded event for db 1");
|
||||
};
|
||||
let event = yield undefined;
|
||||
|
||||
is(event.type, "success", "Got success event for db 1");
|
||||
|
||||
let db = event.target.result;
|
||||
db.onversionchange = function(event) {
|
||||
info("Got versionchange event for db 1");
|
||||
event.target.close();
|
||||
}
|
||||
|
||||
executeSoon(continueToNextStepSync);
|
||||
yield undefined;
|
||||
|
||||
request = indexedDB.open(name, 2);
|
||||
request.onerror = grabEventAndContinueHandler;
|
||||
request.onsuccess = unexpectedSuccessHandler;
|
||||
request.onupgradeneeded = function(event) {
|
||||
info("Got upgradeneeded event for db 2");
|
||||
expectUncaughtException(true);
|
||||
trigger_js_exception_by_calling_a_nonexistent_function();
|
||||
};
|
||||
event = yield undefined;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
is(event.type, "error", "Got an error event for db 2");
|
||||
ok(event.target.error instanceof DOMError, "Request has a DOMError");
|
||||
is(event.target.error.name, "AbortError", "Request has AbortError");
|
||||
|
||||
finishTest();
|
||||
yield undefined;
|
||||
}
|
|
@ -116,6 +116,11 @@ function expectedErrorHandler(name)
|
|||
};
|
||||
}
|
||||
|
||||
function expectUncaughtException(expecting)
|
||||
{
|
||||
// This is dummy for xpcshell test.
|
||||
}
|
||||
|
||||
function ExpectError(name)
|
||||
{
|
||||
this._name = name;
|
||||
|
|
|
@ -76,6 +76,7 @@ skip-if = toolkit == 'android' # bug 864843
|
|||
[test_setVersion_abort.js]
|
||||
[test_setVersion_events.js]
|
||||
[test_setVersion_exclusion.js]
|
||||
[test_setVersion_throw.js]
|
||||
[test_success_events_after_abort.js]
|
||||
[test_table_locks.js]
|
||||
[test_table_rollback.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче