зеркало из https://github.com/mozilla/pjs.git
Bug 685995 - DOM chrome worker tests do not really test anything; r=ted
--HG-- extra : rebase_source : 818071f95ee10917811e16dc42d4073d23035146
This commit is contained in:
Родитель
6c56afb773
Коммит
febeea131e
|
@ -145,6 +145,7 @@ _CHROME_TEST_FILES = \
|
|||
chromeWorker_subworker.js \
|
||||
test_workersDisabled.xul \
|
||||
workersDisabled_worker.js \
|
||||
dom_worker_helper.js \
|
||||
$(NULL)
|
||||
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var gRemainingTests = 0;
|
||||
|
||||
function waitForWorkerFinish() {
|
||||
if (gRemainingTests == 0) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
++gRemainingTests;
|
||||
}
|
||||
|
||||
function finish() {
|
||||
--gRemainingTests;
|
||||
if (gRemainingTests == 0) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
|
@ -11,23 +11,24 @@
|
|||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
function test()
|
||||
{
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
|
||||
var worker = new ChromeWorker("chromeWorker_worker.js");
|
||||
worker.onmessage = function(event) {
|
||||
is(event.data, "Done!", "Wrong message!");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
}
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.message);
|
||||
worker.terminate();
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
}
|
||||
worker.postMessage("go");
|
||||
}
|
||||
|
|
|
@ -11,20 +11,21 @@
|
|||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
function test()
|
||||
{
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
|
||||
var worker;
|
||||
|
||||
function done()
|
||||
{
|
||||
worker = null;
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
}
|
||||
|
||||
function messageCallback(event) {
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=123456
|
|||
-->
|
||||
<window title="Mozilla Bug 123456"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -57,11 +56,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=123456
|
|||
* Create a worker to access file properties.
|
||||
*/
|
||||
function accessFileProperties(file, expectedSize, expectedType) {
|
||||
waitForWorkerFinish();
|
||||
|
||||
var worker = new Worker("file_worker.js");
|
||||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
|
@ -69,11 +70,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=123456
|
|||
is(event.data.type, expectedType, "type proproperty accessed from worker is incorrect.");
|
||||
is(event.data.name, file.name, "name proproperty accessed from worker is incorrect.");
|
||||
is(event.data.mozFullPath, file.mozFullPath, "mozFullPath proproperty accessed from worker is not the same as on main thread.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.postMessage(file);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -62,18 +61,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
console.log(event.data);
|
||||
is(event.data.size, file.size, "size of file posted from worker does not match file posted to worker.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var blob = file.mozSlice();
|
||||
worker.postMessage(blob);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -61,7 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
|
@ -70,12 +69,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
} else {
|
||||
is(event.data.size, expectedSize, "size proproperty accessed from worker is not the same as on main thread.");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var blob = file.mozSlice();
|
||||
worker.postMessage(blob);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -62,18 +61,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
is(event.data.size, expectedLength, "size property of slice is incorrect.");
|
||||
is(event.data.type, contentType ? contentType : blob.type, "type property of slice is incorrect.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var params = {blob: blob, start: start, end: end, contentType: contentType};
|
||||
worker.postMessage(params);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -62,7 +61,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
|
@ -70,11 +69,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
is(event.data.type, file.type, "type of file posted from worker does not match file posted to worker.");
|
||||
is(event.data.name, file.name, "name of file posted from worker does not match file posted to worker.");
|
||||
is(event.data.mozFullPath, file.mozFullPath, "mozFullPath of file posted from worker does not match file posted to worker.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.postMessage(file);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -61,17 +60,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
is(event.data, expectedText, "Text from sliced blob in worker is incorrect.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var params = {blob: blob, start: start, end: end};
|
||||
worker.postMessage(params);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -82,19 +81,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
is(event.data.bin, fileData, "readAsBinaryString in worker returned incorrect result.");
|
||||
is(event.data.url, convertToDataURL("application/octet-stream", fileData), "readAsDataURL in worker returned incorrect result.");
|
||||
is(event.data.arrayBuffer.byteLength, fileData.length, "readAsArrayBuffer returned buffer of incorrect length.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var params = {file: createFileWithData(fileData), encoding: encoding};
|
||||
|
||||
worker.postMessage(params);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,20 +104,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var k = 0;
|
||||
worker.onmessage = function(event) {
|
||||
is(event.data.url, expected[k], "readAsDataURL in worker returned incorrect result when reusing FileReaderSync.");
|
||||
k++;
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
for (var i = 0; i < files.length; ++i) {
|
||||
var params = {file: files[i], encoding: undefined};
|
||||
worker.postMessage(params);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,19 +129,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var k = 0;
|
||||
worker.onmessage = function(event) {
|
||||
is(event.data.text, expected[k++], "readAsText in worker returned incorrect result when reusing FileReaderSync.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
for (var i = 0; i < fileData.length; ++i) {
|
||||
var params = {file: createFileWithData(fileData[i]), encoding: undefined};
|
||||
worker.postMessage(params);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,19 +157,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
var view = new Uint8Array(event.data.arrayBuffer);
|
||||
is(event.data.arrayBuffer.byteLength, fileData.length, "readAsArrayBuffer returned buffer of incorrect length.");
|
||||
is(String.fromCharCode.apply(String, view), fileData, "readAsArrayBuffer returned buffer containing incorrect data.");
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
var params = {file: createFileWithData(fileData), encoding: undefined};
|
||||
|
||||
worker.postMessage(params);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -60,13 +59,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
if(event.data == undefined) {
|
||||
// Worker returns undefined when tests have finished running.
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
} else {
|
||||
// Otherwise worker will return results of tests to be evaluated.
|
||||
is(event.data.actual, event.data.expected, event.data.message);
|
||||
|
@ -74,7 +73,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
};
|
||||
|
||||
worker.postMessage(file);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Run worker which creates exceptions.
|
||||
|
|
|
@ -6,10 +6,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
-->
|
||||
<window title="Mozilla Bug 664783"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
@ -61,7 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "Worker had an error: " + event.data);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
|
@ -73,11 +72,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=664783
|
|||
is(event.data.name, file.name, "name proproperty accessed from worker is incorrect.");
|
||||
is(event.data.mozFullPath, file.mozFullPath, "mozFullPath proproperty accessed from worker is not the same as on main thread.");
|
||||
}
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
};
|
||||
|
||||
worker.postMessage(file);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
|
||||
// Empty file.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
onload="test();">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="dom_worker_helper.js"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
@ -30,11 +31,11 @@
|
|||
worker.onmessage = function(event) {
|
||||
is(event.data, message, "Good message.");
|
||||
prefs.clearUserPref(enabledPref);
|
||||
SimpleTest.finish();
|
||||
finish();
|
||||
}
|
||||
worker.postMessage(message);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
waitForWorkerFinish();
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче