]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/jquery/src/sizzle/test/data/testinit.js
1c49c7abadd1eba13afbcc609ab95e287f3e950c
[rbdr/dotfiles] / atom / packages / ex-mode / node_modules / space-pen / node_modules / jquery / src / sizzle / test / data / testinit.js
1 var fireNative,
2 jQuery = this.jQuery || "jQuery", // For testing .noConflict()
3 $ = this.$ || "$",
4 originaljQuery = jQuery,
5 original$ = $;
6
7 (function() {
8 // Config parameter to force basic code paths
9 QUnit.config.urlConfig.push({
10 id: "basic",
11 label: "Bypass optimizations",
12 tooltip: "Force use of the most basic code by disabling native querySelectorAll; contains; compareDocumentPosition"
13 });
14 if ( QUnit.urlParams.basic ) {
15 document.querySelectorAll = null;
16 document.documentElement.contains = null;
17 document.documentElement.compareDocumentPosition = null;
18 // Return array of length two to pass assertion
19 // But support should be false as its not native
20 document.getElementsByClassName = function() { return [ 0, 1 ]; };
21 }
22 })();
23
24 /**
25 * Returns an array of elements with the given IDs
26 * @example q("main", "foo", "bar")
27 * @result [<div id="main">, <span id="foo">, <input id="bar">]
28 */
29 function q() {
30 var r = [],
31 i = 0;
32
33 for ( ; i < arguments.length; i++ ) {
34 r.push( document.getElementById( arguments[i] ) );
35 }
36 return r;
37 }
38
39 /**
40 * Asserts that a select matches the given IDs
41 * @param {String} a - Assertion name
42 * @param {String} b - Sizzle selector
43 * @param {String} c - Array of ids to construct what is expected
44 * @example t("Check for something", "//[a]", ["foo", "baar"]);
45 * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
46 */
47 function t( a, b, c ) {
48 var f = Sizzle(b),
49 s = "",
50 i = 0;
51
52 for ( ; i < f.length; i++ ) {
53 s += ( s && "," ) + '"' + f[ i ].id + '"';
54 }
55
56 deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
57 }
58
59 /**
60 * Add random number to url to stop caching
61 *
62 * @example url("data/test.html")
63 * @result "data/test.html?10538358428943"
64 *
65 * @example url("data/test.php?foo=bar")
66 * @result "data/test.php?foo=bar&10538358345554"
67 */
68 function url( value ) {
69 return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
70 }
71
72 var createWithFriesXML = function() {
73 var string = '<?xml version="1.0" encoding="UTF-8"?> \
74 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" \
75 xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
76 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \
77 <soap:Body> \
78 <jsconf xmlns="http://www.example.com/ns1"> \
79 <response xmlns:ab="http://www.example.com/ns2"> \
80 <meta> \
81 <component id="seite1" class="component"> \
82 <properties xmlns:cd="http://www.example.com/ns3"> \
83 <property name="prop1"> \
84 <thing /> \
85 <value>1</value> \
86 </property> \
87 <property name="prop2"> \
88 <thing att="something" /> \
89 </property> \
90 <foo_bar>foo</foo_bar> \
91 </properties> \
92 </component> \
93 </meta> \
94 </response> \
95 </jsconf> \
96 </soap:Body> \
97 </soap:Envelope>';
98
99 return jQuery.parseXML( string );
100 };
101
102 fireNative = document.createEvent ?
103 function( node, type ) {
104 var event = document.createEvent("HTMLEvents");
105 event.initEvent( type, true, true );
106 node.dispatchEvent( event );
107 } :
108 function( node, type ) {
109 var event = document.createEventObject();
110 node.fireEvent( "on" + type, event );
111 };
112
113 function testIframeWithCallback( title, fileName, func ) {
114 test( title, function() {
115 var iframe;
116
117 stop();
118 window.iframeCallback = function() {
119 var self = this,
120 args = arguments;
121 setTimeout(function() {
122 window.iframeCallback = undefined;
123 iframe.remove();
124 func.apply( self, args );
125 func = function() {};
126 start();
127 }, 0 );
128 };
129 iframe = jQuery( "<div/>" ).css({ position: "absolute", width: "500px", left: "-600px" })
130 .append( jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) ) )
131 .appendTo( "#qunit-fixture" );
132 });
133 };
134 window.iframeCallback = undefined;
135
136 function moduleTeardown() {}