OLD | NEW |
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 function gczeal(z) | 565 function gczeal(z) |
566 { | 566 { |
567 var javascriptoptions = new Preferences('javascript.options.'); | 567 var javascriptoptions = new Preferences('javascript.options.'); |
568 javascriptoptions.setIntPref('gczeal', Number(z)); | 568 javascriptoptions.setIntPref('gczeal', Number(z)); |
569 } | 569 } |
570 | 570 |
| 571 var gJit = { content: undefined, chrome: undefined }; |
| 572 |
| 573 function jit(on) |
| 574 { |
| 575 var jitoptions = new Preferences('javascript.options.jit.'); |
| 576 |
| 577 if (typeof gJit.content == 'undefined') |
| 578 { |
| 579 gJit.content = jitoptions.getBoolPref('content'); |
| 580 gJit.chrome = jitoptions.getBoolPref('chrome'); |
| 581 } |
| 582 |
| 583 if (on) |
| 584 { |
| 585 jitoptions.setBoolPref('content', true); |
| 586 jitoptions.setBoolPref('chrome', false); |
| 587 } |
| 588 else |
| 589 { |
| 590 jitoptions.setBoolPref('content', false); |
| 591 jitoptions.setBoolPref('chrome', false); |
| 592 } |
| 593 } |
| 594 |
571 var gVersion = 150; | 595 var gVersion = 150; |
572 | 596 |
573 function jsTestDriverBrowserInit() | 597 function jsTestDriverBrowserInit() |
574 { | 598 { |
575 if (typeof dump != 'function') | 599 if (typeof dump != 'function') |
576 { | 600 { |
577 dump = print; | 601 dump = print; |
578 } | 602 } |
579 | 603 |
580 optionsInit(); | 604 optionsInit(); |
581 optionsClear(); | 605 optionsClear(); |
582 | 606 |
583 if (document.location.search.indexOf('?') != 0) | 607 if (document.location.search.indexOf('?') != 0) |
584 { | 608 { |
585 // not called with a query string | 609 // not called with a query string |
586 return; | 610 return; |
587 } | 611 } |
588 | 612 |
589 var re = /test=([^;]+);language=(language|type);([a-zA-Z0-9.=;\/]+)/; | 613 var properties = {}; |
590 var matches = re.exec(document.location.search); | 614 var fields = document.location.search.slice(1).split(';'); |
591 | 615 for (var ifield = 0; ifield < fields.length; ifield++) |
592 // testpath http://machine/path-to-suite/sub-suite/test.js | |
593 var testpath = matches[1]; | |
594 var attribute = matches[2]; | |
595 var value = matches[3]; | |
596 | |
597 if (testpath) | |
598 { | 616 { |
599 gTestPath = testpath; | 617 var propertycaptures = /^([^=]+)=(.*)$/.exec(fields[ifield]); |
| 618 if (!propertycaptures) |
| 619 { |
| 620 properties[fields[ifield]] = true; |
| 621 } |
| 622 else |
| 623 { |
| 624 properties[propertycaptures[1]] = decodeURIComponent(propertycaptures[2]); |
| 625 if (propertycaptures[1] == 'language') |
| 626 { |
| 627 // language=(type|language);mimetype |
| 628 properties.mimetype = fields[ifield+1]; |
| 629 } |
| 630 } |
600 } | 631 } |
601 | 632 |
602 var ise4x = /e4x\//.test(testpath); | 633 if (properties.language != 'type') |
603 | |
604 var gczealmatches = /gczeal=([0-9]*)/.exec(document.location.search); | |
605 | |
606 if (gczealmatches) | |
607 { | 634 { |
608 var zeal = Number(gczealmatches[1]); | 635 try |
609 gczeal(zeal); | 636 { |
| 637 properties.version = /javascript([.0-9]+)/.exec(properties.mimetype)[1]; |
| 638 } |
| 639 catch(ex) |
| 640 { |
| 641 } |
610 } | 642 } |
611 | 643 |
612 var versionmatches = /version=([.0-9]*)/.exec(value); | 644 if (!properties.version && navigator.userAgent.indexOf('Gecko/') != -1) |
613 | |
614 if (!versionmatches) | |
615 { | 645 { |
616 gVersion = 150; | 646 // If the version is not specified, and the browser is Gecko, |
617 } | 647 // adjust the version to match the suite version. |
618 else | 648 if (properties.test.match(/^js1_6/)) |
619 { | 649 { |
620 gVersion = 10*parseInt(versionmatches[1].replace(/\./g, '')); | 650 properties.version = '1.6'; |
| 651 } |
| 652 else if (properties.test.match(/^js1_7/)) |
| 653 { |
| 654 properties.version = '1.7'; |
| 655 } |
| 656 else if (properties.test.match(/^js1_8/)) |
| 657 { |
| 658 properties.version = '1.8'; |
| 659 } |
| 660 else if (properties.test.match(/^js1_8_1/)) |
| 661 { |
| 662 properties.version = '1.8'; |
| 663 } |
| 664 else |
| 665 { |
| 666 properties.version = '1.5'; |
| 667 } |
621 } | 668 } |
622 | 669 |
623 var testpathparts = testpath.split(/\//); | 670 gTestPath = properties.test; |
| 671 |
| 672 gVersion = 10*parseInt(properties.version.replace(/\./g, '')); |
| 673 |
| 674 if (properties.gczeal) |
| 675 { |
| 676 gczeal(Number(properties.gczeal)); |
| 677 } |
| 678 |
| 679 /* |
| 680 * since the default setting of jit changed from false to true |
| 681 * in http://hg.mozilla.org/tracemonkey/rev/685e00e68be9 |
| 682 * bisections which depend upon jit settings can be thrown off. |
| 683 * default jit(false) to make bisections depending upon jit settings |
| 684 * consistent over time. This is not needed in shell tests as the default |
| 685 * jit setting has not changed there. |
| 686 */ |
| 687 |
| 688 jit(properties.jit); |
| 689 |
| 690 var testpathparts = properties.test.split(/\//); |
624 | 691 |
625 if (testpathparts.length < 3) | 692 if (testpathparts.length < 3) |
626 { | 693 { |
627 // must have at least suitepath/subsuite/testcase.js | 694 // must have at least suitepath/subsuite/testcase.js |
628 return; | 695 return; |
629 } | 696 } |
630 var suitepath = testpathparts.slice(0,testpathparts.length-2).join('/'); | 697 var suitepath = testpathparts.slice(0,testpathparts.length-2).join('/'); |
631 var subsuite = testpathparts[testpathparts.length - 2]; | 698 var subsuite = testpathparts[testpathparts.length - 2]; |
632 var test = testpathparts[testpathparts.length - 1]; | 699 var test = testpathparts[testpathparts.length - 1]; |
633 | 700 |
634 outputscripttag(suitepath + '/shell.js', attribute, value, | 701 document.write('<title>' + suitepath + '/' + subsuite + '/' + test + '<\/title
>'); |
635 ise4x); | |
636 outputscripttag(suitepath + '/browser.js', attribute, value, | |
637 ise4x); | |
638 outputscripttag(suitepath + '/' + subsuite + '/shell.js', attribute, value, | |
639 ise4x); | |
640 outputscripttag(suitepath + '/' + subsuite + '/browser.js', attribute, value, | |
641 ise4x); | |
642 outputscripttag(suitepath + '/' + subsuite + '/' + test, attribute, value, | |
643 ise4x); | |
644 | 702 |
645 document.write('<title>' + suitepath + '/' + subsuite + '/' + test + | 703 // XXX bc - the first document.written script is ignored if the protocol |
646 '<\/title>'); | 704 // is file:. insert an empty script tag, to work around it. |
| 705 document.write('<script></script>'); |
647 | 706 |
648 outputscripttag('js-test-driver-end.js', attribute, value, | 707 outputscripttag(suitepath + '/shell.js', properties); |
649 false); | 708 outputscripttag(suitepath + '/browser.js', properties); |
| 709 outputscripttag(suitepath + '/' + subsuite + '/shell.js', properties); |
| 710 outputscripttag(suitepath + '/' + subsuite + '/browser.js', properties); |
| 711 outputscripttag(suitepath + '/' + subsuite + '/' + test, properties, |
| 712 » properties.e4x || /e4x\//.test(properties.test)); |
| 713 outputscripttag('js-test-driver-end.js', properties); |
650 return; | 714 return; |
651 } | 715 } |
652 | 716 |
653 function outputscripttag(src, attribute, value, ise4x) | 717 function outputscripttag(src, properties, e4x) |
654 { | 718 { |
655 if (!src) | 719 if (!src) |
656 { | 720 { |
657 return; | 721 return; |
658 } | 722 } |
659 | 723 |
| 724 if (e4x) |
| 725 { |
| 726 // e4x requires type=mimetype;e4x=1 |
| 727 properties.language = 'type'; |
| 728 } |
| 729 |
660 var s = '<script src="' + src + '" '; | 730 var s = '<script src="' + src + '" '; |
661 | 731 |
662 if (ise4x) | 732 if (properties.language != 'type') |
663 { | 733 { |
664 if (attribute == 'type') | 734 s += 'language="javascript'; |
| 735 if (properties.version) |
665 { | 736 { |
666 value += ';e4x=1 '; | 737 s += properties.version; |
667 } | |
668 else | |
669 { | |
670 s += ' type="text/javascript'; | |
671 if (gVersion != 150) | |
672 { | |
673 s += ';version=' + gVersion/100; | |
674 } | |
675 s += ';e4x=1" '; | |
676 } | 738 } |
677 } | 739 } |
678 | 740 else |
679 s += attribute + '="' + value + '"><\/script>'; | 741 { |
| 742 s += 'type="' + properties.mimetype; |
| 743 if (properties.version) |
| 744 { |
| 745 s += ';version=' + properties.version; |
| 746 } |
| 747 if (e4x) |
| 748 { |
| 749 s += ';e4x=1'; |
| 750 } |
| 751 } |
| 752 s += '"><\/script>'; |
680 | 753 |
681 document.write(s); | 754 document.write(s); |
682 } | 755 } |
683 | 756 |
684 function jsTestDriverEnd() | 757 function jsTestDriverEnd() |
685 { | 758 { |
686 // gDelayTestDriverEnd is used to | 759 // gDelayTestDriverEnd is used to |
687 // delay collection of the test result and | 760 // delay collection of the test result and |
688 // signal to Spider so that tests can continue | 761 // signal to Spider so that tests can continue |
689 // to run after page load has fired. They are | 762 // to run after page load has fired. They are |
690 // responsible for setting gDelayTestDriverEnd = true | 763 // responsible for setting gDelayTestDriverEnd = true |
691 // then when completed, setting gDelayTestDriverEnd = false | 764 // then when completed, setting gDelayTestDriverEnd = false |
692 // then calling jsTestDriverEnd() | 765 // then calling jsTestDriverEnd() |
693 | 766 |
694 if (gDelayTestDriverEnd) | 767 if (gDelayTestDriverEnd) |
695 { | 768 { |
696 return; | 769 return; |
697 } | 770 } |
698 | 771 |
699 window.onerror = null; | 772 window.onerror = null; |
700 | 773 |
701 try | 774 try |
702 { | 775 { |
703 var javascriptoptions = new Preferences('javascript.options.'); | 776 var javascriptoptions = new Preferences('javascript.options.'); |
704 javascriptoptions.clearPref('gczeal'); | 777 javascriptoptions.clearPref('gczeal'); |
| 778 |
| 779 var jitoptions = new Preferences('javascript.options.jit.'); |
| 780 if (typeof gJit.content != 'undefined') |
| 781 { |
| 782 jitoptions.setBoolPref('content', gJit.content); |
| 783 } |
| 784 |
| 785 if (typeof gJit.chrome != 'undefined') |
| 786 { |
| 787 jitoptions.setBoolPref('chrome', gJit.chrome); |
| 788 } |
| 789 |
705 optionsReset(); | 790 optionsReset(); |
706 } | 791 } |
707 catch(ex) | 792 catch(ex) |
708 { | 793 { |
709 dump('jsTestDriverEnd ' + ex); | 794 dump('jsTestDriverEnd ' + ex); |
710 } | 795 } |
711 | 796 |
712 if (window.opener && window.opener.runNextTest) | 797 if (window.opener && window.opener.runNextTest) |
713 { | 798 { |
714 if (window.opener.reportCallBack) | 799 if (window.opener.reportCallBack) |
715 { | 800 { |
716 window.opener.reportCallBack(window.opener.gWindow); | 801 window.opener.reportCallBack(window.opener.gWindow); |
717 } | 802 } |
718 setTimeout('window.opener.runNextTest()', 250); | 803 setTimeout('window.opener.runNextTest()', 250); |
719 } | 804 } |
720 else | 805 else |
721 { | 806 { |
722 for (var i = 0; i < gTestcases.length; i++) | 807 for (var i = 0; i < gTestcases.length; i++) |
723 { | 808 { |
724 gTestcases[i].dump(); | 809 gTestcases[i].dump(); |
725 } | 810 } |
726 | 811 |
727 // tell Spider page is complete | 812 // tell Spider page is complete |
728 gPageCompleted = true; | 813 gPageCompleted = true; |
729 } | 814 } |
730 } | 815 } |
731 | 816 |
732 jsTestDriverBrowserInit(); | 817 jsTestDriverBrowserInit(); |
OLD | NEW |