Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Cleanup composite addon: Use callback registration instead of overwriting them. Set...
[qunit.git] / addons / composite / qunit-composite.js
1 (function( QUnit ) {
2
3 QUnit.extend( QUnit, {
4         testSuites: function( suites ) {
5                 QUnit.begin(function() {
6                         QUnit.initIframe();
7                 });
8
9                 for ( var i = 0; i < suites.length; i++ ) {
10                         (function( suite ) {
11                                 asyncTest( suite, function() {
12                                         QUnit.runSuite( suite );
13                                 });
14                         }( suites[i] ) );
15                 }
16                 QUnit.done(function() {
17                         this.iframe.style.display = "none";
18                 });
19         },
20
21         runSuite: function( suite ) {
22                 this.iframe.setAttribute( "src", suite );
23         },
24
25         initIframe: function() {
26                 var body = document.body,
27                         iframe = this.iframe = document.createElement( "iframe" ),
28                         iframeWin;
29
30                 iframe.className = "qunit-subsuite";
31                 body.appendChild( iframe );
32
33                 function onIframeLoad() {
34                         var module, test,
35                                 count = 0;
36
37
38                         iframeWin.QUnit.moduleStart(function( data ) {
39                                 // capture module name for messages
40                                 module = data.name;
41                         });
42
43                         iframeWin.QUnit.testStart(function( data ) {
44                                 // capture test name for messages
45                                 test = data.name;
46                         });
47                         iframeWin.QUnit.testDone(function() {
48                                 test = null;
49                         });
50
51                         iframeWin.QUnit.log(function( data ) {
52                                 if (test === null) {
53                                         return;
54                                 }
55                                 // pass all test details through to the main page
56                                 var message = module + ": " + test + ": " + data.message;
57                                 expect( ++count );
58                                 QUnit.push( data.result, data.actual, data.expected, message );
59                         });
60
61                         iframeWin.QUnit.done(function() {
62                                 // start the wrapper test from the main page
63                                 start();
64                         });
65                 }
66                 QUnit.addEvent( iframe, "load", onIframeLoad );
67
68                 iframeWin = iframe.contentWindow;
69         }
70 });
71
72 QUnit.testStart(function( data ) {
73         // update the test status to show which test suite is running
74         QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br>&nbsp;";
75 });
76
77 QUnit.testDone(function() {
78         var current = QUnit.id( this.config.current.id ),
79                 children = current.children,
80                 src = this.iframe.src;
81
82         // undo the auto-expansion of failed tests
83         for ( var i = 0; i < children.length; i++ ) {
84                 if ( children[i].nodeName === "OL" ) {
85                         children[i].style.display = "none";
86                 }
87         }
88
89         QUnit.addEvent(current, "dblclick", function( e ) {
90                 var target = e && e.target ? e.target : window.event.srcElement;
91                 if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
92                         target = target.parentNode;
93                 }
94                 if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
95                         window.location = src;
96                 }
97         });
98
99         current.getElementsByTagName('a')[0].href = src;
100 });
101
102 }( QUnit ) );

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf