1// svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump text + pixel results
2if (self.testRunner)
3 testRunner.dumpAsText(self.enablePixelTesting);
4
5var description, debug, successfullyParsed, errorMessage, silentTestPass, didPassSomeTestsSilently, didFailSomeTests;
6
7silentTestPass = false;
8didPassSomeTestsSilently = false;
9didFailSomeTests = false;
10
11(function() {
12
13 function createHTMLElement(tagName)
14 {
15 // FIXME: In an XML document, document.createElement() creates an element with a null namespace URI.
16 // So, we need use document.createElementNS() to explicitly create an element with the specified
17 // tag name in the HTML namespace. We can remove this function and use document.createElement()
18 // directly once we fix <https://bugs.webkit.org/show_bug.cgi?id=131074>.
19 if (document.createElementNS)
20 return document.createElementNS("http://www.w3.org/1999/xhtml", tagName);
21 return document.createElement(tagName);
22 }
23
24 function getOrCreate(id, tagName)
25 {
26 var element = document.getElementById(id);
27 if (element)
28 return element;
29
30 element = createHTMLElement(tagName);
31 element.id = id;
32 var refNode;
33 var parent = document.body || document.documentElement;
34 if (id == "description")
35 refNode = getOrCreate("console", "div");
36 else
37 refNode = parent.firstChild;
38
39 parent.insertBefore(element, refNode);
40 return element;
41 }
42
43 description = function description(msg, quiet)
44 {
45 // For MSIE 6 compatibility
46 var span = createHTMLElement("span");
47 if (quiet)
48 span.innerHTML = '<p>' + msg + '</p><p>On success, you will see no "<span class="fail">FAIL</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
49 else
50 span.innerHTML = '<p>' + msg + '</p><p>On success, you will see a series of "<span class="pass">PASS</span>" messages, followed by "<span class="pass">TEST COMPLETE</span>".</p>';
51
52 var description = getOrCreate("description", "p");
53 if (description.firstChild)
54 description.replaceChild(span, description.firstChild);
55 else
56 description.appendChild(span);
57 };
58
59 debug = function debug(msg)
60 {
61 var span = createHTMLElement("span");
62 getOrCreate("console", "div").appendChild(span); // insert it first so XHTML knows the namespace
63 span.innerHTML = msg + '<br />';
64 };
65
66 var css =
67 ".pass {" +
68 "font-weight: bold;" +
69 "color: green;" +
70 "}" +
71 ".fail {" +
72 "font-weight: bold;" +
73 "color: red;" +
74 "}" +
75 "#console {" +
76 "white-space: pre-wrap;" +
77 "font-family: monospace;" +
78 "}";
79
80 function insertStyleSheet()
81 {
82 var styleElement = createHTMLElement("style");
83 styleElement.textContent = css;
84 (document.head || document.documentElement).appendChild(styleElement);
85 }
86
87 if (!isWorker())
88 insertStyleSheet();
89
90 self.onerror = function(message)
91 {
92 errorMessage = message;
93 };
94
95})();
96
97function isWorker()
98{
99 // It's conceivable that someone would stub out 'document' in a worker so
100 // also check for childNodes, an arbitrary DOM-related object that is
101 // meaningless in a WorkerContext.
102 return (typeof document === 'undefined' || typeof document.childNodes === 'undefined') && !!self.importScripts;
103}
104
105function descriptionQuiet(msg) { description(msg, true); }
106
107function escapeHTML(text)
108{
109 return text.replace(/&/g, "&").replace(/</g, "<").replace(/\0/g, "\\0");
110}
111
112function testPassed(msg)
113{
114 if (silentTestPass)
115 didPassSomeTestsSilently = true;
116 else
117 debug('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
118}
119
120function testFailed(msg)
121{
122 didFailSomeTests = true;
123 debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
124}
125
126function areNumbersEqual(_actual, _expected)
127{
128 if (_expected === 0)
129 return _actual === _expected && (1/_actual) === (1/_expected);
130 if (_actual === _expected)
131 return true;
132 if (typeof(_expected) == "number" && isNaN(_expected))
133 return typeof(_actual) == "number" && isNaN(_actual);
134 return false;
135}
136
137function areArraysEqual(_a, _b)
138{
139 try {
140 if (_a.length !== _b.length)
141 return false;
142 for (var i = 0; i < _a.length; i++)
143 if (!areNumbersEqual(_a[i], _b[i]))
144 return false;
145 } catch (ex) {
146 return false;
147 }
148 return true;
149}
150
151function isMinusZero(n)
152{
153 // the only way to tell 0 from -0 in JS is the fact that 1/-0 is
154 // -Infinity instead of Infinity
155 return n === 0 && 1/n < 0;
156}
157
158function isTypedArray(array)
159{
160 return array instanceof Int8Array
161 || array instanceof Int16Array
162 || array instanceof Int32Array
163 || array instanceof Uint8Array
164 || array instanceof Uint8ClampedArray
165 || array instanceof Uint16Array
166 || array instanceof Uint32Array
167 || array instanceof Float32Array
168 || array instanceof Float64Array;
169}
170
171function isResultCorrect(_actual, _expected)
172{
173 if (areNumbersEqual(_actual, _expected))
174 return true;
175 if (_expected
176 && (Object.prototype.toString.call(_expected) ==
177 Object.prototype.toString.call([])
178 || isTypedArray(_expected)))
179 return areArraysEqual(_actual, _expected);
180 return false;
181}
182
183function stringify(v)
184{
185 if (v === 0 && 1/v < 0)
186 return "-0";
187 else if (isTypedArray(v))
188 return v.__proto__.constructor.name + ":[" + Array.prototype.join.call(v, ",") + "]";
189 else
190 return "" + v;
191}
192
193function evalAndLog(_a, _quiet)
194{
195 if (typeof _a != "string")
196 debug("WARN: tryAndLog() expects a string argument");
197
198 // Log first in case things go horribly wrong or this causes a sync event.
199 if (!_quiet)
200 debug(_a);
201
202 var _av;
203 try {
204 _av = eval(_a);
205 } catch (e) {
206 testFailed(_a + " threw exception " + e);
207 }
208 return _av;
209}
210
211function shouldBe(_a, _b, quiet)
212{
213 if (typeof _a != "string" || typeof _b != "string")
214 debug("WARN: shouldBe() expects string arguments");
215 var exception;
216 var _av;
217 try {
218 _av = eval(_a);
219 } catch (e) {
220 exception = e;
221 }
222 var _bv = eval(_b);
223
224 if (exception)
225 testFailed(_a + " should be " + stringify(_bv) + ". Threw exception " + exception);
226 else if (isResultCorrect(_av, _bv)) {
227 if (!quiet) {
228 testPassed(_a + " is " + _b);
229 }
230 } else if (typeof(_av) == typeof(_bv))
231 testFailed(_a + " should be " + stringify(_bv) + ". Was " + stringify(_av) + ".");
232 else
233 testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
234}
235
236function shouldBeEqualToNumber(a, b)
237{
238 if (typeof a !== "string" || typeof b !== "number")
239 debug("WARN: shouldBeEqualToNumber() expects a string and a number arguments");
240 var unevaledString = JSON.stringify(b);
241 shouldBe(a, unevaledString);
242}
243
244function dfgShouldBe(theFunction, _a, _b)
245{
246 if (typeof theFunction != "function" || typeof _a != "string" || typeof _b != "string")
247 debug("WARN: dfgShouldBe() expects a function and two strings");
248 noInline(theFunction);
249 var exception;
250 var values = [];
251
252 // Defend against tests that muck with numeric properties on array.prototype.
253 values.__proto__ = null;
254 values.push = Array.prototype.push;
255
256 try {
257 while (!dfgCompiled({f:theFunction}))
258 values.push(eval(_a));
259 values.push(eval(_a));
260 } catch (e) {
261 exception = e;
262 }
263
264 var _bv = eval(_b);
265 if (exception)
266 testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (values.length + 1) + ", threw exception " + exception);
267 else {
268 var allPassed = true;
269 for (var i = 0; i < values.length; ++i) {
270 var _av = values[i];
271 if (isResultCorrect(_av, _bv))
272 continue;
273 if (typeof(_av) == typeof(_bv))
274 testFailed(_a + " should be " + stringify(_bv) + ". On iteration " + (i + 1) + ", was " + stringify(_av) + ".");
275 else
276 testFailed(_a + " should be " + stringify(_bv) + " (of type " + typeof _bv + "). On iteration " + (i + 1) + ", was " + _av + " (of type " + typeof _av + ").");
277 allPassed = false;
278 }
279 if (allPassed)
280 testPassed(_a + " is " + _b + " on all iterations including after DFG tier-up.");
281 }
282
283 return values.length;
284}
285
286// Execute condition every 5 milliseconds until it succeeds.
287function _waitForCondition(condition, completionHandler)
288{
289 if (condition())
290 completionHandler();
291 else
292 setTimeout(_waitForCondition, 5, condition, completionHandler);
293}
294
295function shouldBecomeEqual(_a, _b, completionHandler)
296{
297 if (typeof _a != "string" || typeof _b != "string")
298 debug("WARN: shouldBecomeEqual() expects string arguments");
299
300 var condition = function() {
301 var exception;
302 var _av;
303 try {
304 _av = eval(_a);
305 } catch (e) {
306 exception = e;
307 }
308 var _bv = eval(_b);
309 if (exception)
310 testFailed(_a + " should become " + _bv + ". Threw exception " + exception);
311 if (isResultCorrect(_av, _bv)) {
312 testPassed(_a + " became " + _b);
313 return true;
314 }
315 return false;
316 };
317 _waitForCondition(condition, completionHandler);
318}
319
320function shouldBecomeEqualToString(value, reference, completionHandler)
321{
322 if (typeof value !== "string" || typeof reference !== "string")
323 debug("WARN: shouldBecomeEqualToString() expects string arguments");
324 var unevaledString = JSON.stringify(reference);
325 shouldBecomeEqual(value, unevaledString, completionHandler);
326}
327
328function shouldBeType(_a, _type) {
329 var exception;
330 var _av;
331 try {
332 _av = eval(_a);
333 } catch (e) {
334 exception = e;
335 }
336
337 var _typev = eval(_type);
338 if (_av instanceof _typev) {
339 testPassed(_a + " is an instance of " + _type);
340 } else {
341 testFailed(_a + " is not an instance of " + _type);
342 }
343}
344
345// Variant of shouldBe()--confirms that result of eval(_to_eval) is within
346// numeric _tolerance of numeric _target.
347function shouldBeCloseTo(_to_eval, _target, _tolerance, quiet)
348{
349 if (typeof _to_eval != "string") {
350 testFailed("shouldBeCloseTo() requires string argument _to_eval. was type " + typeof _to_eval);
351 return;
352 }
353 if (typeof _target != "number") {
354 testFailed("shouldBeCloseTo() requires numeric argument _target. was type " + typeof _target);
355 return;
356 }
357 if (typeof _tolerance != "number") {
358 testFailed("shouldBeCloseTo() requires numeric argument _tolerance. was type " + typeof _tolerance);
359 return;
360 }
361
362 var _result;
363 try {
364 _result = eval(_to_eval);
365 } catch (e) {
366 testFailed(_to_eval + " should be within " + _tolerance + " of "
367 + _target + ". Threw exception " + e);
368 return;
369 }
370
371 if (typeof(_result) != typeof(_target)) {
372 testFailed(_to_eval + " should be of type " + typeof _target
373 + " but was of type " + typeof _result);
374 } else if (Math.abs(_result - _target) <= _tolerance) {
375 if (!quiet) {
376 testPassed(_to_eval + " is within " + _tolerance + " of " + _target);
377 }
378 } else {
379 testFailed(_to_eval + " should be within " + _tolerance + " of " + _target
380 + ". Was " + _result + ".");
381 }
382}
383
384function shouldNotBe(_a, _b, quiet)
385{
386 if (typeof _a != "string" || typeof _b != "string")
387 debug("WARN: shouldNotBe() expects string arguments");
388 var exception;
389 var _av;
390 try {
391 _av = eval(_a);
392 } catch (e) {
393 exception = e;
394 }
395 var _bv = eval(_b);
396
397 if (exception)
398 testFailed(_a + " should not be " + _bv + ". Threw exception " + exception);
399 else if (!isResultCorrect(_av, _bv)) {
400 if (!quiet) {
401 testPassed(_a + " is not " + _b);
402 }
403 } else
404 testFailed(_a + " should not be " + _bv + ".");
405}
406
407function shouldBecomeDifferent(_a, _b, completionHandler)
408{
409 if (typeof _a != "string" || typeof _b != "string")
410 debug("WARN: shouldBecomeDifferent() expects string arguments");
411
412 var condition = function() {
413 var exception;
414 var _av;
415 try {
416 _av = eval(_a);
417 } catch (e) {
418 exception = e;
419 }
420 var _bv = eval(_b);
421 if (exception)
422 testFailed(_a + " should became not equal to " + _bv + ". Threw exception " + exception);
423 if (!isResultCorrect(_av, _bv)) {
424 testPassed(_a + " became different from " + _b);
425 return true;
426 }
427 return false;
428 };
429 _waitForCondition(condition, completionHandler);
430}
431
432function shouldBeTrue(_a) { shouldBe(_a, "true"); }
433function shouldBeTrueQuiet(_a) { shouldBe(_a, "true", true); }
434function shouldBeFalse(_a) { shouldBe(_a, "false"); }
435function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
436function shouldBeNull(_a) { shouldBe(_a, "null"); }
437function shouldBeZero(_a) { shouldBe(_a, "0"); }
438
439function shouldBeEqualToString(a, b)
440{
441 if (typeof a !== "string" || typeof b !== "string")
442 debug("WARN: shouldBeEqualToString() expects string arguments");
443 var unevaledString = JSON.stringify(b);
444 shouldBe(a, unevaledString);
445}
446
447function shouldNotBeEqualToString(a, b)
448{
449 if (typeof a !== "string" || typeof b !== "string")
450 debug("WARN: shouldBeEqualToString() expects string arguments");
451 var unevaledString = JSON.stringify(b);
452 shouldNotBe(a, unevaledString);
453}
454function shouldBeEmptyString(_a) { shouldBeEqualToString(_a, ""); }
455
456function shouldEvaluateTo(actual, expected) {
457 // A general-purpose comparator. 'actual' should be a string to be
458 // evaluated, as for shouldBe(). 'expected' may be any type and will be
459 // used without being eval'ed.
460 if (expected == null) {
461 // Do this before the object test, since null is of type 'object'.
462 shouldBeNull(actual);
463 } else if (typeof expected == "undefined") {
464 shouldBeUndefined(actual);
465 } else if (typeof expected == "function") {
466 // All this fuss is to avoid the string-arg warning from shouldBe().
467 try {
468 actualValue = eval(actual);
469 } catch (e) {
470 testFailed("Evaluating " + actual + ": Threw exception " + e);
471 return;
472 }
473 shouldBe("'" + actualValue.toString().replace(/\n/g, "") + "'",
474 "'" + expected.toString().replace(/\n/g, "") + "'");
475 } else if (typeof expected == "object") {
476 shouldBeTrue(actual + " == '" + expected + "'");
477 } else if (typeof expected == "string") {
478 shouldBe(actual, expected);
479 } else if (typeof expected == "boolean") {
480 shouldBe("typeof " + actual, "'boolean'");
481 if (expected)
482 shouldBeTrue(actual);
483 else
484 shouldBeFalse(actual);
485 } else if (typeof expected == "number") {
486 shouldBe(actual, stringify(expected));
487 } else {
488 debug(expected + " is unknown type " + typeof expected);
489 shouldBeTrue(actual, "'" +expected.toString() + "'");
490 }
491}
492
493function shouldBeNonZero(_a)
494{
495 var exception;
496 var _av;
497 try {
498 _av = eval(_a);
499 } catch (e) {
500 exception = e;
501 }
502
503 if (exception)
504 testFailed(_a + " should be non-zero. Threw exception " + exception);
505 else if (_av != 0)
506 testPassed(_a + " is non-zero.");
507 else
508 testFailed(_a + " should be non-zero. Was " + _av);
509}
510
511function shouldBeNonNull(_a)
512{
513 var exception;
514 var _av;
515 try {
516 _av = eval(_a);
517 } catch (e) {
518 exception = e;
519 }
520
521 if (exception)
522 testFailed(_a + " should be non-null. Threw exception " + exception);
523 else if (_av != null)
524 testPassed(_a + " is non-null.");
525 else
526 testFailed(_a + " should be non-null. Was " + _av);
527}
528
529function shouldBeUndefined(_a)
530{
531 var exception;
532 var _av;
533 try {
534 _av = eval(_a);
535 } catch (e) {
536 exception = e;
537 }
538
539 if (exception)
540 testFailed(_a + " should be undefined. Threw exception " + exception);
541 else if (typeof _av == "undefined")
542 testPassed(_a + " is undefined.");
543 else
544 testFailed(_a + " should be undefined. Was " + _av);
545}
546
547function shouldBeDefined(_a)
548{
549 var exception;
550 var _av;
551 try {
552 _av = eval(_a);
553 } catch (e) {
554 exception = e;
555 }
556
557 if (exception)
558 testFailed(_a + " should be defined. Threw exception " + exception);
559 else if (_av !== undefined)
560 testPassed(_a + " is defined.");
561 else
562 testFailed(_a + " should be defined. Was " + _av);
563}
564
565function shouldBeGreaterThanOrEqual(_a, _b) {
566 if (typeof _a != "string" || typeof _b != "string")
567 debug("WARN: shouldBeGreaterThanOrEqual expects string arguments");
568
569 var exception;
570 var _av;
571 try {
572 _av = eval(_a);
573 } catch (e) {
574 exception = e;
575 }
576 var _bv = eval(_b);
577
578 if (exception)
579 testFailed(_a + " should be >= " + _b + ". Threw exception " + exception);
580 else if (typeof _av == "undefined" || _av < _bv)
581 testFailed(_a + " should be >= " + _b + ". Was " + _av + " (of type " + typeof _av + ").");
582 else
583 testPassed(_a + " is >= " + _b);
584}
585
586function expectTrue(v, msg) {
587 if (v) {
588 testPassed(msg);
589 } else {
590 testFailed(msg);
591 }
592}
593
594function shouldNotThrow(_a) {
595 try {
596 eval(_a);
597 testPassed(_a + " did not throw exception.");
598 } catch (e) {
599 testFailed(_a + " should not throw exception. Threw exception " + e + ".");
600 }
601}
602
603function shouldThrow(_a, _e)
604{
605 var exception;
606 var _av;
607 try {
608 _av = eval(_a);
609 } catch (e) {
610 exception = e;
611 }
612
613 var _ev;
614 if (_e)
615 _ev = eval(_e);
616
617 if (exception) {
618 if (typeof _e == "undefined" || exception == _ev)
619 testPassed(_a + " threw exception " + exception + ".");
620 else
621 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + ".");
622 } else if (typeof _av == "undefined")
623 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined.");
624 else
625 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + ".");
626}
627
628function shouldHaveHadError(message)
629{
630 if (errorMessage) {
631 if (!message)
632 testPassed("Got expected error");
633 else if (errorMessage.indexOf(message) !== -1)
634 testPassed("Got expected error: '" + message + "'");
635 else
636 testFailed("Unexpexted error '" + message + "'");
637 } else
638 testFailed("Missing expexted error");
639 errorMessage = undefined;
640}
641
642function gc() {
643 if (typeof GCController !== "undefined")
644 GCController.collect();
645 else {
646 var gcRec = function (n) {
647 if (n < 1)
648 return {};
649 var temp = {i: "ab" + i + (i / 100000)};
650 temp += "foo";
651 gcRec(n-1);
652 };
653 for (var i = 0; i < 1000; i++)
654 gcRec(10)
655 }
656}
657
658function dfgCompiled(argument)
659{
660 var numberOfCompiles = "compiles" in argument ? argument.compiles : 1;
661
662 if (!("f" in argument))
663 throw new Error("dfgCompiled called with invalid argument.");
664
665 if (argument.f instanceof Array) {
666 for (var i = 0; i < argument.f.length; ++i) {
667 if (testRunner.numberOfDFGCompiles(argument.f[i]) < numberOfCompiles)
668 return false;
669 }
670 } else {
671 if (testRunner.numberOfDFGCompiles(argument.f) < numberOfCompiles)
672 return false;
673 }
674
675 return true;
676}
677
678function dfgIncrement(argument)
679{
680 if (!self.testRunner)
681 return argument.i;
682
683 if (argument.i < argument.n)
684 return argument.i;
685
686 if (didFailSomeTests)
687 return argument.i;
688
689 if (!dfgCompiled(argument))
690 return "start" in argument ? argument.start : 0;
691
692 return argument.i;
693}
694
695function noInline(theFunction)
696{
697 if (!self.testRunner)
698 return;
699
700 testRunner.neverInlineFunction(theFunction);
701}
702
703function isSuccessfullyParsed()
704{
705 // FIXME: Remove this and only report unexpected syntax errors.
706 if (!errorMessage)
707 successfullyParsed = true;
708 shouldBeTrue("successfullyParsed");
709 if (silentTestPass && didPassSomeTestsSilently)
710 debug("Passed some tests silently.");
711 if (silentTestPass && didFailSomeTests)
712 debug("Some tests failed.");
713 debug('<br /><span class="pass">TEST COMPLETE</span>');
714}
715
716// It's possible for an async test to call finishJSTest() before js-test-post.js
717// has been parsed.
718function finishJSTest()
719{
720 wasFinishJSTestCalled = true;
721 if (!self.wasPostTestScriptParsed)
722 return;
723 isSuccessfullyParsed();
724 if (self.jsTestIsAsync && self.testRunner)
725 testRunner.notifyDone();
726}
727
728function startWorker(testScriptURL, shared)
729{
730 self.jsTestIsAsync = true;
731 debug('Starting worker: ' + testScriptURL);
732 var worker = shared ? new SharedWorker(testScriptURL, "Shared Worker") : new Worker(testScriptURL);
733 worker.onmessage = function(event)
734 {
735 var workerPrefix = "[Worker] ";
736 if (event.data.length < 5 || event.data.charAt(4) != ':') {
737 debug(workerPrefix + event.data);
738 return;
739 }
740 var code = event.data.substring(0, 4);
741 var payload = workerPrefix + event.data.substring(5);
742 if (code == "PASS")
743 testPassed(payload);
744 else if (code == "FAIL")
745 testFailed(payload);
746 else if (code == "DESC")
747 description(payload);
748 else if (code == "DONE")
749 finishJSTest();
750 else
751 debug(workerPrefix + event.data);
752 };
753
754 worker.onerror = function(event)
755 {
756 debug('Got error from worker: ' + event.message);
757 finishJSTest();
758 }
759
760 if (shared) {
761 worker.port.onmessage = function(event) { worker.onmessage(event); };
762 worker.port.start();
763 }
764 return worker;
765}
766
767if (isWorker()) {
768 var workerPort = self;
769 if (self.name == "Shared Worker") {
770 self.onconnect = function(e) {
771 workerPort = e.ports[0];
772 workerPort.onmessage = function(event)
773 {
774 var colon = event.data.indexOf(":");
775 if (colon == -1) {
776 testFailed("Unrecognized message to shared worker: " + event.data);
777 return;
778 }
779 var code = event.data.substring(0, colon);
780 var payload = event.data.substring(colon + 1);
781 try {
782 if (code == "IMPORT")
783 importScripts(payload);
784 else
785 testFailed("Unrecognized message to shared worker: " + event.data);
786 } catch (ex) {
787 testFailed("Caught exception in shared worker onmessage: " + ex);
788 }
789 };
790 };
791 }
792 description = function(msg, quiet) {
793 workerPort.postMessage('DESC:' + msg);
794 }
795 testFailed = function(msg) {
796 workerPort.postMessage('FAIL:' + msg);
797 }
798 testPassed = function(msg) {
799 workerPort.postMessage('PASS:' + msg);
800 }
801 finishJSTest = function() {
802 workerPort.postMessage('DONE:');
803 }
804 debug = function(msg) {
805 workerPort.postMessage(msg);
806 }
807}