summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/jquery
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/ajax/jquery')
-rw-r--r--dom/tests/mochitest/ajax/jquery/ChangeLog.txt98
-rw-r--r--dom/tests/mochitest/ajax/jquery/GPL-LICENSE.txt278
-rw-r--r--dom/tests/mochitest/ajax/jquery/MIT-LICENSE.txt20
-rw-r--r--dom/tests/mochitest/ajax/jquery/dist/jquery.js3549
-rw-r--r--dom/tests/mochitest/ajax/jquery/manifest.json1
-rw-r--r--dom/tests/mochitest/ajax/jquery/mochitest.ini37
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/cow.jpgbin0 -> 1635 bytes
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/dashboard.xml11
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/iframe.html8
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/json_assigned_obj.js1
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/json_obj.js1
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/name.html1
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/offset/absolute.html39
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/offset/fixed.html33
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/offset/relative.html31
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/offset/scroll.html39
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/offset/static.html31
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/offset/table.html43
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/test.html7
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/test.js3
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/test2.html5
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/test3.html3
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/testrunner.js334
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/testsuite.css117
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/data/with_fries.xml25
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/fix.html48
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/index.html187
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/offset.html27
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/test.js41
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/ajax.js837
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/core.js1700
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/dimensions.js86
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/event.js348
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/fx.js435
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/offset.js164
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/unit/selector.js224
-rw-r--r--dom/tests/mochitest/ajax/jquery/test_jQuery.html24
-rw-r--r--dom/tests/mochitest/ajax/jquery/version.txt1
38 files changed, 8837 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/jquery/ChangeLog.txt b/dom/tests/mochitest/ajax/jquery/ChangeLog.txt
new file mode 100644
index 0000000000..6d834c1967
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/ChangeLog.txt
@@ -0,0 +1,98 @@
+== jQuery ChangeLog ==
+
+== 1.2.2 ==
+
+* show is now element aware (uses default display type instead of just forcing block)
+* New special events api: jQuery.events.special
+* ready is now a real event and can be bound, unbound and triggered.
+* mouseenter and mouseleave now work on all supported browsers
+* The hover helper method now uses the mouseenter and mouseleave events
+* New offset test suite test/offset.html (requires your pop-up blocker to be disabled)
+* Refactored the width and height methods (fixes lots of bugs)
+* Fixed event memory leaks in IE (html, remove, empty also no longer leak memory)
+* Fixed window/document width/height values
+* Fixed event.pageX and event.pageY in IE
+
+== 1.2 ==
+
+=== 1.1.3 ===
+* Always create an ActiveXObject when it is available instead of the XMLHttpRequest, even in IE7
+* Removed XMLHttpRequest shadowing, may break code that relies on existence of that function for browser checking
+* ...
+
+=== 1.1.2 ===
+
+* Event handlers (like element.onclick) are now removed when no more functions are bound to the event.
+* Fixed DOM Manipulations for form elements.
+* Fixed jQuery.isFunction to return false on nodes.
+* Fixed jQuery.className.has, escaping regex characters in className (for metadata)
+* Fixed an issue in IE where an event on a cloned element is fired during a .clone() inside of an event handler.
+* Fixed IE ID selectors selecting by the name attribute.
+* Change: Events are now internally stored in elem.$events rather than elem.events (due to a nasty bug relating to DOM 0 expandos).
+* .attr('href') is now consistent in all browsers.
+* @href is now consistent in all browsers.
+* Fixed the slideDown flickering bug.
+* Having a \r endline in $("...") caused a never-ending loop.
+* Fixed IE6 AJAX memory leak
+* Fixed bug in pushStack, reporting an element at [0] in a jQuery object with length 0
+
+=== 1.1.1 ===
+
+* Setting the numerical value of a css property failed, for example: .css("opacity",0.5) (also occurred with zIndex, fontWeight)
+* Calling $(..., jqobj) with a context of a jQuery object failed.
+* Accessing a property on an element that doesn't exist caused an error, for example: $("#foobar").attr("id")
+* Calling .load() without a callback caused an error.
+* You couldn't cancel an event that was triggered using .trigger() or .click() (for example).
+* .add()ing a single DOM element to a jQuery object was broken.
+* Passing in undefined values to a $.post() caused weird errors to occur.
+* Accessing child nodes within an xml document didn't work properly.
+* jQuery.isFunction() was unable to reliably determine a function, in a cross-browser way.
+* Triggering a .click() failed in IE.
+* Triggered click handlers were executed twice in most browsers.
+* A newline passed into $(...) caused Firefox to go into a never-ending loop.
+* Calling $.post() without any data caused an error.
+* Calling a descendant selector after a child selector caused strange results, for example: $("ul > li ul")
+* Triggered events did not occur if an event handler was not bound for that event.
+
+== 1.1 ==
+
+* Massive speed-ups (4x-10x) in the selector engine.
+* You can now unbind event handlers from within themselves
+* Added new .one( "type", fn ) method
+* text(String) now escapes HTML
+* Added attr(String,Function) to calculate the value
+* Performming .click(), .blur(), .focus(), .submit() will actually trigger the browsers default action for those events.
+* Added global settings for AJAX (in addition to timeout), use $.ajaxSetup() to modify them
+* Implemented a better error handling for ajax requests. Exceptions caused by dropping connections are now handled, too.
+* Improved event fixing (Opera provides event.srcElement, must ignore it if target is available; only create pageX if clientX is available)
+* Fixed nth-child selectors to start on the right number
+* jQuery is no longer destructive. Doing var a = $("a"); a.find("span"); does not change the original "a" variable.
+* Fixed synchronous requests
+* Fixed ID with context selectors (eg. div #id doesn't ignore "div" anymore)
+* Fixed docs for html(): Now mentions that is not available for XML documents
+* Improved AJAX docs (eg. more examples for $.ajax)
+* Documented filter(Function), a very powerful approach for custom filtering
+* Improved docs for FX module, merging method descriptions and marking optional arguments
+* Improved docs for append, prepend, before and after, merging the three pairs into one
+* Improved show/hide animations to show only hidden and hide only visible elements
+* Removed .oneEvent() and .unEvent() helper methods.
+* Removed all CSS helper methods.
+* Removed most attribute helper methods.
+* Removed the (undocumented) .find( "selector", fn ) for all destructive methods.
+* $.get, $.getIfModified, $.post, $.getScript and $.getJSON now all pass through the XMLHttpRequest as returned by $.ajax
+
+== 1.0.4 ==
+
+* Tons of bug fixes
+* Extensions to $.ajax: $.ajax accepts additonal options: beforeSend, async and processData; returns XMLHttpRequest to allow manual aborting of requests, see docs for details
+* AJAX module: the public $.ajax API is now used internally (for $.get/$.post etc.); loading scripts works now much more reliable on all browers except Safari
+* New global ajax handler: ajaxSend - called before an ajax request is sent
+* Extensions to global ajax handlers: ajaxSend, ajaxSuccess, ajaxError and ajaxComplete get XMLHttpRequest and settings passed as arguments
+* Extensions to event handling: pageX and pageY are available x-browser (IE does not provide native pageX/Y)
+* Improved docs: $(String) method has now two seperate descriptions, one for selecting elements, one for creating (html on-the-fly)
+* FX module: Most inline stlyes added by animations are now removed when the animation is complete, eg. height style when animating height (exception: display styles)
+* Added note to attr(String, Object) about issues with setting the name property on input elements
+* Seperated internal stuff from get() into set()
+* Merged the two API examples for each() into one more precise example
+* Improved docs for $.browser and added docs for $.boxModel
+* Docs for the jQuery constructor $() were improved: There is now $(String expression[, Object context]) and $(String html)
diff --git a/dom/tests/mochitest/ajax/jquery/GPL-LICENSE.txt b/dom/tests/mochitest/ajax/jquery/GPL-LICENSE.txt
new file mode 100644
index 0000000000..11dddd00ef
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/GPL-LICENSE.txt
@@ -0,0 +1,278 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
diff --git a/dom/tests/mochitest/ajax/jquery/MIT-LICENSE.txt b/dom/tests/mochitest/ajax/jquery/MIT-LICENSE.txt
new file mode 100644
index 0000000000..d4215f0e42
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/MIT-LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2008 John Resig, http://jquery.com/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/dom/tests/mochitest/ajax/jquery/dist/jquery.js b/dom/tests/mochitest/ajax/jquery/dist/jquery.js
new file mode 100644
index 0000000000..a28e7cd65c
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/dist/jquery.js
@@ -0,0 +1,3549 @@
+(function(){
+/*
+ * jQuery 1.2.6 - New Wave Javascript
+ *
+ * Copyright (c) 2008 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2008-05-24 11:09:21 -0700 (Sat, 24 May 2008) $
+ * $Rev: 5683 $
+ */
+
+// Map over jQuery in case of overwrite
+var _jQuery = window.jQuery,
+// Map over the $ in case of overwrite
+ _$ = window.$;
+
+var jQuery = window.jQuery = window.$ = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+};
+
+// A simple way to check for HTML strings or ID strings
+// (both of which we optimize for)
+var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
+
+// Is it a simple selector
+ isSimple = /^.[^:#\[\.]*$/,
+
+// Will speed up references to undefined, and allows munging its name.
+ undefined;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ // Make sure that a selection was provided
+ selector = selector || document;
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+ // Handle HTML strings
+ if ( typeof selector == "string" ) {
+ // Are we dealing with HTML string or an ID?
+ var match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] )
+ selector = jQuery.clean( [ match[1] ], context );
+
+ // HANDLE: $("#id")
+ else {
+ var elem = document.getElementById( match[3] );
+
+ // Make sure an element was located
+ if ( elem ){
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id != match[3] )
+ return jQuery().find( selector );
+
+ // Otherwise, we inject the element directly into the jQuery object
+ return jQuery( elem );
+ }
+ selector = [];
+ }
+
+ // HANDLE: $(expr, [context])
+ // (which is just equivalent to: $(content).find(expr)
+ } else
+ return jQuery( context ).find( selector );
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) )
+ return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
+
+ return this.setArray(jQuery.makeArray(selector));
+ },
+
+ // The current version of jQuery being used
+ jquery: "1.2.6",
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ // The number of elements contained in the matched element set
+ length: 0,
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == undefined ?
+
+ // Return a 'clean' array
+ jQuery.makeArray( this ) :
+
+ // Return just the object
+ this[ num ];
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ Array.prototype.push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ var ret = -1;
+
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem && elem.jquery ? elem[0] : elem
+ , this );
+ },
+
+ attr: function( name, value, type ) {
+ var options = name;
+
+ // Look for the case where we're accessing a style value
+ if ( name.constructor == String )
+ if ( value === undefined )
+ return this[0] && jQuery[ type || "attr" ]( this[0], name );
+
+ else {
+ options = {};
+ options[ name ] = value;
+ }
+
+ // Check to see if we're setting style values
+ return this.each(function(i){
+ // Set all the styles
+ for ( name in options )
+ jQuery.attr(
+ type ?
+ this.style :
+ this,
+ name, jQuery.prop( this, options[ name ], type, i, name )
+ );
+ });
+ },
+
+ css: function( key, value ) {
+ // ignore negative width and height values
+ if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
+ value = undefined;
+ return this.attr( key, value, "curCSS" );
+ },
+
+ text: function( text ) {
+ if ( typeof text != "object" && text != null )
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+
+ var ret = "";
+
+ jQuery.each( text || this, function(){
+ jQuery.each( this.childNodes, function(){
+ if ( this.nodeType != 8 )
+ ret += this.nodeType != 1 ?
+ this.nodeValue :
+ jQuery.fn.text( [ this ] );
+ });
+ });
+
+ return ret;
+ },
+
+ wrapAll: function( html ) {
+ if ( this[0] )
+ // The elements to wrap the target around
+ jQuery( html, this[0].ownerDocument )
+ .clone()
+ .insertBefore( this[0] )
+ .map(function(){
+ var elem = this;
+
+ while ( elem.firstChild )
+ elem = elem.firstChild;
+
+ return elem;
+ })
+ .append(this);
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function(){
+ jQuery( this ).contents().wrapAll( html );
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function(){
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, false, function(elem){
+ if (this.nodeType == 1)
+ this.appendChild( elem );
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, true, function(elem){
+ if (this.nodeType == 1)
+ this.insertBefore( elem, this.firstChild );
+ });
+ },
+
+ before: function() {
+ return this.domManip(arguments, false, false, function(elem){
+ this.parentNode.insertBefore( elem, this );
+ });
+ },
+
+ after: function() {
+ return this.domManip(arguments, false, true, function(elem){
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ },
+
+ end: function() {
+ return this.prevObject || jQuery( [] );
+ },
+
+ find: function( selector ) {
+ var elems = jQuery.map(this, function(elem){
+ return jQuery.find( selector, elem );
+ });
+
+ return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
+ jQuery.unique( elems ) :
+ elems );
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function(){
+ if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var clone = this.cloneNode(true),
+ container = document.createElement("div");
+ container.appendChild(clone);
+ return jQuery.clean([container.innerHTML])[0];
+ } else
+ return this.cloneNode(true);
+ });
+
+ // Need to set the expando to null on the cloned set if it exists
+ // removeData doesn't work here, IE removes it from the original as well
+ // this is primarily for IE but the data expando shouldn't be copied over in any browser
+ var clone = ret.find("*").andSelf().each(function(){
+ if ( this[ expando ] != undefined )
+ this[ expando ] = null;
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true )
+ this.find("*").andSelf().each(function(i){
+ if (this.nodeType == 3)
+ return;
+ var events = jQuery.data( this, "events" );
+
+ for ( var type in events )
+ for ( var handler in events[ type ] )
+ jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
+ });
+
+ // Return the cloned set
+ return ret;
+ },
+
+ filter: function( selector ) {
+ return this.pushStack(
+ jQuery.isFunction( selector ) &&
+ jQuery.grep(this, function(elem, i){
+ return selector.call( elem, i );
+ }) ||
+
+ jQuery.multiFilter( selector, this ) );
+ },
+
+ not: function( selector ) {
+ if ( selector.constructor == String )
+ // test special case where just one selector is passed in
+ if ( isSimple.test( selector ) )
+ return this.pushStack( jQuery.multiFilter( selector, this, true ) );
+ else
+ selector = jQuery.multiFilter( selector, this );
+
+ var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
+ return this.filter(function() {
+ return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
+ });
+ },
+
+ add: function( selector ) {
+ return this.pushStack( jQuery.unique( jQuery.merge(
+ this.get(),
+ typeof selector == 'string' ?
+ jQuery( selector ) :
+ jQuery.makeArray( selector )
+ )));
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.multiFilter( selector, this ).length > 0;
+ },
+
+ hasClass: function( selector ) {
+ return this.is( "." + selector );
+ },
+
+ val: function( value ) {
+ if ( value == undefined ) {
+
+ if ( this.length ) {
+ var elem = this[0];
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type == "select-one";
+
+ // Nothing was selected
+ if ( index < 0 )
+ return null;
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
+
+ // We don't need an array for one selects
+ if ( one )
+ return value;
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+
+ // Everything else, we just grab the value
+ } else
+ return (this[0].value || "").replace(/\r/g, "");
+
+ }
+
+ return undefined;
+ }
+
+ if( value.constructor == Number )
+ value += '';
+
+ return this.each(function(){
+ if ( this.nodeType != 1 )
+ return;
+
+ if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
+ this.checked = (jQuery.inArray(this.value, value) >= 0 ||
+ jQuery.inArray(this.name, value) >= 0);
+
+ else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(value);
+
+ jQuery( "option", this ).each(function(){
+ this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
+ jQuery.inArray( this.text, values ) >= 0);
+ });
+
+ if ( !values.length )
+ this.selectedIndex = -1;
+
+ } else
+ this.value = value;
+ });
+ },
+
+ html: function( value ) {
+ return value == undefined ?
+ (this[0] ?
+ this[0].innerHTML :
+ null) :
+ this.empty().append( value );
+ },
+
+ replaceWith: function( value ) {
+ return this.after( value ).remove();
+ },
+
+ eq: function( i ) {
+ return this.slice( i, i + 1 );
+ },
+
+ slice: function() {
+ return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function(elem, i){
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ },
+
+ data: function( key, value ){
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length )
+ data = jQuery.data( this[0], key );
+
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
+ jQuery.data( this, key, value );
+ });
+ },
+
+ removeData: function( key ){
+ return this.each(function(){
+ jQuery.removeData( this, key );
+ });
+ },
+
+ domManip: function( args, table, reverse, callback ) {
+ var clone = this.length > 1, elems;
+
+ return this.each(function(){
+ if ( !elems ) {
+ elems = jQuery.clean( args, this.ownerDocument );
+
+ if ( reverse )
+ elems.reverse();
+ }
+
+ var obj = this;
+
+ if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
+ obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
+
+ var scripts = jQuery( [] );
+
+ jQuery.each(elems, function(){
+ var elem = clone ?
+ jQuery( this ).clone( true )[0] :
+ this;
+
+ // execute all scripts after the elements have been injected
+ if ( jQuery.nodeName( elem, "script" ) )
+ scripts = scripts.add( elem );
+ else {
+ // Remove any inner scripts for later evaluation
+ if ( elem.nodeType == 1 )
+ scripts = scripts.add( jQuery( "script", elem ).remove() );
+
+ // Inject the elements into the document
+ callback.call( obj, elem );
+ }
+ });
+
+ scripts.each( evalScript );
+ });
+ }
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+function evalScript( i, elem ) {
+ if ( elem.src )
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+
+ else
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+
+ if ( elem.parentNode )
+ elem.parentNode.removeChild( elem );
+}
+
+function now(){
+ return +new Date;
+}
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
+
+ // Handle a deep copy situation
+ if ( target.constructor == Boolean ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target != "object" && typeof target != "function" )
+ target = {};
+
+ // extend jQuery itself if only one argument is passed
+ if ( length == i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ )
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null )
+ // Extend the base object
+ for ( var name in options ) {
+ var src = target[ name ], copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy )
+ continue;
+
+ // Recurse if we're merging object values
+ if ( deep && copy && typeof copy == "object" && !copy.nodeType )
+ target[ name ] = jQuery.extend( deep,
+ // Never move original objects, clone them
+ src || ( copy.length != null ? [ ] : { } )
+ , copy );
+
+ // Don't bring in undefined values
+ else if ( copy !== undefined )
+ target[ name ] = copy;
+
+ }
+
+ // Return the modified object
+ return target;
+};
+
+var expando = "jQuery" + now(), uuid = 0, windowData = {},
+ // exclude the following css properties to add px
+ exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ // cache defaultView
+ defaultView = document.defaultView || {};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep )
+ window.jQuery = _jQuery;
+
+ return jQuery;
+ },
+
+ // See test/unit/core.js for details concerning this function.
+ isFunction: function( fn ) {
+ return !!fn && typeof fn != "string" && !fn.nodeName &&
+ fn.constructor != Array && /^[\s[]?function/.test( fn + "" );
+ },
+
+ // check if an element is in a (or is an) XML document
+ isXMLDoc: function( elem ) {
+ return elem.documentElement && !elem.body ||
+ elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+ },
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ data = jQuery.trim( data );
+
+ if ( data ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+ if ( jQuery.browser.msie )
+ script.text = data;
+ else
+ script.appendChild( document.createTextNode( data ) );
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
+ },
+
+ cache: {},
+
+ data: function( elem, name, data ) {
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ];
+
+ // Compute a unique ID for the element
+ if ( !id )
+ id = elem[ expando ] = ++uuid;
+
+ // Only generate the data cache if we're
+ // trying to access or manipulate it
+ if ( name && !jQuery.cache[ id ] )
+ jQuery.cache[ id ] = {};
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined )
+ jQuery.cache[ id ][ name ] = data;
+
+ // Return the named cache data, or the ID for the element
+ return name ?
+ jQuery.cache[ id ][ name ] :
+ id;
+ },
+
+ removeData: function( elem, name ) {
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( jQuery.cache[ id ] ) {
+ // Remove the section of cache data
+ delete jQuery.cache[ id ][ name ];
+
+ // If we've removed all the data, remove the element's cache
+ name = "";
+
+ for ( name in jQuery.cache[ id ] )
+ break;
+
+ if ( !name )
+ jQuery.removeData( elem );
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch(e){
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute )
+ elem.removeAttribute( expando );
+ }
+
+ // Completely remove the data cache
+ delete jQuery.cache[ id ];
+ }
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0, length = object.length;
+
+ if ( args ) {
+ if ( length == undefined ) {
+ for ( name in object )
+ if ( callback.apply( object[ name ], args ) === false )
+ break;
+ } else
+ for ( ; i < length; )
+ if ( callback.apply( object[ i++ ], args ) === false )
+ break;
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( length == undefined ) {
+ for ( name in object )
+ if ( callback.call( object[ name ], name, object[ name ] ) === false )
+ break;
+ } else
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
+ }
+
+ return object;
+ },
+
+ prop: function( elem, value, type, i, name ) {
+ // Handle executable functions
+ if ( jQuery.isFunction( value ) )
+ value = value.call( elem, i );
+
+ // Handle passing in a number to a CSS property
+ return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
+ value + "px" :
+ value;
+ },
+
+ className: {
+ // internal only, use addClass("class")
+ add: function( elem, classNames ) {
+ jQuery.each((classNames || "").split(/\s+/), function(i, className){
+ if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
+ elem.className += (elem.className ? " " : "") + className;
+ });
+ },
+
+ // internal only, use removeClass("class")
+ remove: function( elem, classNames ) {
+ if (elem.nodeType == 1)
+ elem.className = classNames != undefined ?
+ jQuery.grep(elem.className.split(/\s+/), function(className){
+ return !jQuery.className.has( classNames, className );
+ }).join(" ") :
+ "";
+ },
+
+ // internal only, use hasClass("class")
+ has: function( elem, className ) {
+ return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
+ }
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options )
+ elem.style[ name ] = old[ name ];
+ },
+
+ css: function( elem, name, force ) {
+ if ( name == "width" || name == "height" ) {
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+
+ function getWH() {
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+ var padding = 0, border = 0;
+ jQuery.each( which, function() {
+ padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ });
+ val -= Math.round(padding + border);
+ }
+
+ if ( jQuery(elem).is(":visible") )
+ getWH();
+ else
+ jQuery.swap( elem, props, getWH );
+
+ return Math.max(0, val);
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style;
+
+ // A helper method for determining if an element's values are broken
+ function color( elem ) {
+ if ( !jQuery.browser.safari )
+ return false;
+
+ // defaultView is cached
+ var ret = defaultView.getComputedStyle( elem, null );
+ return !ret || ret.getPropertyValue("color") == "";
+ }
+
+ // We need to handle opacity special in IE
+ if ( name == "opacity" && jQuery.browser.msie ) {
+ ret = jQuery.attr( style, "opacity" );
+
+ return ret == "" ?
+ "1" :
+ ret;
+ }
+ // Opera sometimes will give the wrong display answer, this fixes it, see #2037
+ if ( jQuery.browser.opera && name == "display" ) {
+ var save = style.outline;
+ style.outline = "0 solid black";
+ style.outline = save;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( name.match( /float/i ) )
+ name = styleFloat;
+
+ if ( !force && style && style[ name ] )
+ ret = style[ name ];
+
+ else if ( defaultView.getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( name.match( /float/i ) )
+ name = "float";
+
+ name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle && !color( elem ) )
+ ret = computedStyle.getPropertyValue( name );
+
+ // If the element isn't reporting its values properly in Safari
+ // then some display: none elements are involved
+ else {
+ var swap = [], stack = [], a = elem, i = 0;
+
+ // Locate all of the parent display: none elements
+ for ( ; a && color(a); a = a.parentNode )
+ stack.unshift(a);
+
+ // Go through and make them visible, but in reverse
+ // (It would be better if we knew the exact display type that they had)
+ for ( ; i < stack.length; i++ )
+ if ( color( stack[ i ] ) ) {
+ swap[ i ] = stack[ i ].style.display;
+ stack[ i ].style.display = "block";
+ }
+
+ // Since we flip the display style, we have to handle that
+ // one special, otherwise get the value
+ ret = name == "display" && swap[ stack.length - 1 ] != null ?
+ "none" :
+ ( computedStyle && computedStyle.getPropertyValue( name ) ) || "";
+
+ // Finally, revert the display styles back
+ for ( i = 0; i < swap.length; i++ )
+ if ( swap[ i ] != null )
+ stack[ i ].style.display = swap[ i ];
+ }
+
+ // We should always get a number back from opacity
+ if ( name == "opacity" && ret == "" )
+ ret = "1";
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(/\-(\w)/g, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = ret || 0;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ clean: function( elems, context ) {
+ var ret = [];
+ context = context || document;
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if (typeof context.createElement == 'undefined')
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+
+ jQuery.each(elems, function(i, elem){
+ if ( !elem )
+ return;
+
+ if ( elem.constructor == Number )
+ elem += '';
+
+ // Convert html string into DOM nodes
+ if ( typeof elem == "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
+ return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
+ all :
+ front + "></" + tag + ">";
+ });
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
+
+ var wrap =
+ // option or optgroup
+ !tags.indexOf("<opt") &&
+ [ 1, "<select multiple='multiple'>", "</select>" ] ||
+
+ !tags.indexOf("<leg") &&
+ [ 1, "<fieldset>", "</fieldset>" ] ||
+
+ tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
+ [ 1, "<table>", "</table>" ] ||
+
+ !tags.indexOf("<tr") &&
+ [ 2, "<table><tbody>", "</tbody></table>" ] ||
+
+ // <thead> matched above
+ (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
+ [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
+
+ !tags.indexOf("<col") &&
+ [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
+
+ // IE can't serialize <link> and <script> tags normally
+ jQuery.browser.msie &&
+ [ 1, "div<div>", "</div>" ] ||
+
+ [ 0, "", "" ];
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( wrap[0]-- )
+ div = div.lastChild;
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( jQuery.browser.msie ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j )
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( /^\s/.test( elem ) )
+ div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
+
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
+ return;
+
+ if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
+ ret.push( elem );
+
+ else
+ ret = jQuery.merge( ret, elem );
+
+ });
+
+ return ret;
+ },
+
+ attr: function( elem, name, value ) {
+ // don't set attributes on text and comment nodes
+ if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
+ return undefined;
+
+ var notxml = !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined,
+ msie = jQuery.browser.msie;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ // IE elem.getAttribute passes even for style
+ if ( elem.tagName ) {
+
+ // These attributes require special treatment
+ var special = /href|src|style/.test( name );
+
+ // Safari mis-reports the default selected property of a hidden option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name == "selected" && jQuery.browser.safari )
+ elem.parentNode.selectedIndex;
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ){
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
+ throw "type property can't be changed";
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
+ return elem.getAttributeNode( name ).nodeValue;
+
+ return elem[ name ];
+ }
+
+ if ( msie && notxml && name == "style" )
+ return jQuery.attr( elem.style, "cssText", value );
+
+ if ( set )
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+
+ var attr = msie && notxml && special
+ // Some attributes require a special call on IE
+ ? elem.getAttribute( name, 2 )
+ : elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+
+ // IE uses filters for opacity
+ if ( msie && name == "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ elem.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
+ (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
+ }
+
+ return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
+ "";
+ }
+
+ name = name.replace(/-([a-z])/ig, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ if ( set )
+ elem[ name ] = value;
+
+ return elem[ name ];
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( /^\s+|\s+$/g, "" );
+ },
+
+ makeArray: function( array ) {
+ var ret = [];
+
+ if( array != null ){
+ var i = array.length;
+ //the window, strings and functions also have 'length'
+ if( i == null || array.split || array.setInterval || array.call )
+ ret[0] = array;
+ else
+ while( i )
+ ret[--i] = array[i];
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ for ( var i = 0, length = array.length; i < length; i++ )
+ // Use === because on IE, window == document
+ if ( array[ i ] === elem )
+ return i;
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ // We have to loop this way because IE & Opera overwrite the length
+ // expando of getElementsByTagName
+ var i = 0, elem, pos = first.length;
+ // Also, we need to make sure that the correct elements are being returned
+ // (IE returns comment nodes in a '*' query)
+ if ( jQuery.browser.msie ) {
+ while ( elem = second[ i++ ] )
+ if ( elem.nodeType != 8 )
+ first[ pos++ ] = elem;
+
+ } else
+ while ( elem = second[ i++ ] )
+ first[ pos++ ] = elem;
+
+ return first;
+ },
+
+ unique: function( array ) {
+ var ret = [], done = {};
+
+ try {
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ var id = jQuery.data( array[ i ] );
+
+ if ( !done[ id ] ) {
+ done[ id ] = true;
+ ret.push( array[ i ] );
+ }
+ }
+
+ } catch( e ) {
+ ret = array;
+ }
+
+ return ret;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ )
+ if ( !inv != !callback( elems[ i ], i ) )
+ ret.push( elems[ i ] );
+
+ return ret;
+ },
+
+ map: function( elems, callback ) {
+ var ret = [];
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ var value = callback( elems[ i ], i );
+
+ if ( value != null )
+ ret[ ret.length ] = value;
+ }
+
+ return ret.concat.apply( [], ret );
+ }
+});
+
+var userAgent = navigator.userAgent.toLowerCase();
+
+// Figure out what browser is being used
+jQuery.browser = {
+ version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
+ safari: /webkit/.test( userAgent ),
+ opera: /opera/.test( userAgent ),
+ msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
+ mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
+};
+
+var styleFloat = jQuery.browser.msie ?
+ "styleFloat" :
+ "cssFloat";
+
+jQuery.extend({
+ // Check to see if the W3C box model is being used
+ boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
+
+ props: {
+ "for": "htmlFor",
+ "class": "className",
+ "float": styleFloat,
+ cssFloat: styleFloat,
+ styleFloat: styleFloat,
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing"
+ }
+});
+
+jQuery.each({
+ parent: function(elem){return elem.parentNode;},
+ parents: function(elem){return jQuery.dir(elem,"parentNode");},
+ next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
+ prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
+ nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
+ prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
+ siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
+ children: function(elem){return jQuery.sibling(elem.firstChild);},
+ contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
+}, function(name, fn){
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = jQuery.map( this, fn );
+
+ if ( selector && typeof selector == "string" )
+ ret = jQuery.multiFilter( selector, ret );
+
+ return this.pushStack( jQuery.unique( ret ) );
+ };
+});
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function(name, original){
+ jQuery.fn[ name ] = function() {
+ var args = arguments;
+
+ return this.each(function(){
+ for ( var i = 0, length = args.length; i < length; i++ )
+ jQuery( args[ i ] )[ original ]( this );
+ });
+ };
+});
+
+jQuery.each({
+ removeAttr: function( name ) {
+ jQuery.attr( this, name, "" );
+ if (this.nodeType == 1)
+ this.removeAttribute( name );
+ },
+
+ addClass: function( classNames ) {
+ jQuery.className.add( this, classNames );
+ },
+
+ removeClass: function( classNames ) {
+ jQuery.className.remove( this, classNames );
+ },
+
+ toggleClass: function( classNames ) {
+ jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
+ },
+
+ remove: function( selector ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
+ // Prevent memory leaks
+ jQuery( "*", this ).add(this).each(function(){
+ jQuery.event.remove(this);
+ jQuery.removeData(this);
+ });
+ if (this.parentNode)
+ this.parentNode.removeChild( this );
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ jQuery( ">*", this ).remove();
+
+ // Remove any remaining nodes
+ while ( this.firstChild )
+ this.removeChild( this.firstChild );
+ }
+}, function(name, fn){
+ jQuery.fn[ name ] = function(){
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.each([ "Height", "Width" ], function(i, name){
+ var type = name.toLowerCase();
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ return this[0] == window ?
+ // Opera reports document.body.client[Width/Height] properly in both quirks and standards
+ jQuery.browser.opera && document.body[ "client" + name ] ||
+
+ // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
+ jQuery.browser.safari && window[ "inner" + name ] ||
+
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
+
+ // Get document width or height
+ this[0] == document ?
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]),
+ Math.max(document.body["offset" + name], document.documentElement["offset" + name])
+ ) :
+
+ // Get or set width or height on the element
+ size == undefined ?
+ // Get width or height on the element
+ (this.length ? jQuery.css( this[0], type ) : null) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, size.constructor == String ? size : size + "px" );
+ };
+});
+
+// Helper function used by the dimensions and offset modules
+function num(elem, prop) {
+ return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
+}var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
+ "(?:[\\w*_-]|\\\\.)" :
+ "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
+ quickChild = new RegExp("^>\\s*(" + chars + "+)"),
+ quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
+ quickClass = new RegExp("^([#.]?)(" + chars + "*)");
+
+jQuery.extend({
+ expr: {
+ "": function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},
+ "#": function(a,i,m){return a.getAttribute("id")==m[2];},
+ ":": {
+ // Position Checks
+ lt: function(a,i,m){return i<m[3]-0;},
+ gt: function(a,i,m){return i>m[3]-0;},
+ nth: function(a,i,m){return m[3]-0==i;},
+ eq: function(a,i,m){return m[3]-0==i;},
+ first: function(a,i){return i==0;},
+ last: function(a,i,m,r){return i==r.length-1;},
+ even: function(a,i){return i%2==0;},
+ odd: function(a,i){return i%2;},
+
+ // Child Checks
+ "first-child": function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},
+ "last-child": function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},
+ "only-child": function(a){return !jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},
+
+ // Parent Checks
+ parent: function(a){return a.firstChild;},
+ empty: function(a){return !a.firstChild;},
+
+ // Text Check
+ contains: function(a,i,m){return (a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},
+
+ // Visibility
+ visible: function(a){return "hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},
+ hidden: function(a){return "hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},
+
+ // Form attributes
+ enabled: function(a){return !a.disabled;},
+ disabled: function(a){return a.disabled;},
+ checked: function(a){return a.checked;},
+ selected: function(a){return a.selected||jQuery.attr(a,"selected");},
+
+ // Form elements
+ text: function(a){return "text"==a.type;},
+ radio: function(a){return "radio"==a.type;},
+ checkbox: function(a){return "checkbox"==a.type;},
+ file: function(a){return "file"==a.type;},
+ password: function(a){return "password"==a.type;},
+ submit: function(a){return "submit"==a.type;},
+ image: function(a){return "image"==a.type;},
+ reset: function(a){return "reset"==a.type;},
+ button: function(a){return "button"==a.type||jQuery.nodeName(a,"button");},
+ input: function(a){return /input|select|textarea|button/i.test(a.nodeName);},
+
+ // :has()
+ has: function(a,i,m){return jQuery.find(m[3],a).length;},
+
+ // :header
+ header: function(a){return /h\d/i.test(a.nodeName);},
+
+ // :animated
+ animated: function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}
+ }
+ },
+
+ // The regular expressions that power the parsing engine
+ parse: [
+ // Match: [@value='test'], [@foo]
+ /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
+
+ // Match: :contains('foo')
+ /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
+
+ // Match: :even, :last-child, #id, .class
+ new RegExp("^([:.#]*)(" + chars + "+)")
+ ],
+
+ multiFilter: function( expr, elems, not ) {
+ var old, cur = [];
+
+ while ( expr && expr != old ) {
+ old = expr;
+ var f = jQuery.filter( expr, elems, not );
+ expr = f.t.replace(/^\s*,\s*/, "" );
+ cur = not ? elems = f.r : jQuery.merge( cur, f.r );
+ }
+
+ return cur;
+ },
+
+ find: function( t, context ) {
+ // Quickly handle non-string expressions
+ if ( typeof t != "string" )
+ return [ t ];
+
+ // check to make sure context is a DOM element or a document
+ if ( context && context.nodeType != 1 && context.nodeType != 9)
+ return [ ];
+
+ // Set the correct context (if none is provided)
+ context = context || document;
+
+ // Initialize the search
+ var ret = [context], done = [], last, nodeName;
+
+ // Continue while a selector expression exists, and while
+ // we're no longer looping upon ourselves
+ while ( t && last != t ) {
+ var r = [];
+ last = t;
+
+ t = jQuery.trim(t);
+
+ var foundToken = false,
+
+ // An attempt at speeding up child selectors that
+ // point to a specific element tag
+ re = quickChild,
+
+ m = re.exec(t);
+
+ if ( m ) {
+ nodeName = m[1].toUpperCase();
+
+ // Perform our own iteration and filter
+ for ( var i = 0; ret[i]; i++ )
+ for ( var c = ret[i].firstChild; c; c = c.nextSibling )
+ if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) )
+ r.push( c );
+
+ ret = r;
+ t = t.replace( re, "" );
+ if ( t.indexOf(" ") == 0 ) continue;
+ foundToken = true;
+ } else {
+ re = /^([>+~])\s*(\w*)/i;
+
+ if ( (m = re.exec(t)) != null ) {
+ r = [];
+
+ var merge = {};
+ nodeName = m[2].toUpperCase();
+ m = m[1];
+
+ for ( var j = 0, rl = ret.length; j < rl; j++ ) {
+ var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
+ for ( ; n; n = n.nextSibling )
+ if ( n.nodeType == 1 ) {
+ var id = jQuery.data(n);
+
+ if ( m == "~" && merge[id] ) break;
+
+ if (!nodeName || n.nodeName.toUpperCase() == nodeName ) {
+ if ( m == "~" ) merge[id] = true;
+ r.push( n );
+ }
+
+ if ( m == "+" ) break;
+ }
+ }
+
+ ret = r;
+
+ // And remove the token
+ t = jQuery.trim( t.replace( re, "" ) );
+ foundToken = true;
+ }
+ }
+
+ // See if there's still an expression, and that we haven't already
+ // matched a token
+ if ( t && !foundToken ) {
+ // Handle multiple expressions
+ if ( !t.indexOf(",") ) {
+ // Clean the result set
+ if ( context == ret[0] ) ret.shift();
+
+ // Merge the result sets
+ done = jQuery.merge( done, ret );
+
+ // Reset the context
+ r = ret = [context];
+
+ // Touch up the selector string
+ t = " " + t.substr(1,t.length);
+
+ } else {
+ // Optimize for the case nodeName#idName
+ var re2 = quickID;
+ var m = re2.exec(t);
+
+ // Re-organize the results, so that they're consistent
+ if ( m ) {
+ m = [ 0, m[2], m[3], m[1] ];
+
+ } else {
+ // Otherwise, do a traditional filter check for
+ // ID, class, and element selectors
+ re2 = quickClass;
+ m = re2.exec(t);
+ }
+
+ m[2] = m[2].replace(/\\/g, "");
+
+ var elem = ret[ret.length-1];
+
+ // Try to do a global search by ID, where we can
+ if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
+ // Optimization for HTML document case
+ var oid = elem.getElementById(m[2]);
+
+ // Do a quick check for the existence of the actual ID attribute
+ // to avoid selecting by the name attribute in IE
+ // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
+ if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
+ oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
+
+ // Do a quick check for node name (where applicable) so
+ // that div#foo searches will be really fast
+ ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
+ } else {
+ // We need to find all descendant elements
+ for ( var i = 0; ret[i]; i++ ) {
+ // Grab the tag name being searched for
+ var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
+
+ // Handle IE7 being really dumb about <object>s
+ if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
+ tag = "param";
+
+ r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
+ }
+
+ // It's faster to filter by class and be done with it
+ if ( m[1] == "." )
+ r = jQuery.classFilter( r, m[2] );
+
+ // Same with ID filtering
+ if ( m[1] == "#" ) {
+ var tmp = [];
+
+ // Try to find the element with the ID
+ for ( var i = 0; r[i]; i++ )
+ if ( r[i].getAttribute("id") == m[2] ) {
+ tmp = [ r[i] ];
+ break;
+ }
+
+ r = tmp;
+ }
+
+ ret = r;
+ }
+
+ t = t.replace( re2, "" );
+ }
+
+ }
+
+ // If a selector string still exists
+ if ( t ) {
+ // Attempt to filter it
+ var val = jQuery.filter(t,r);
+ ret = r = val.r;
+ t = jQuery.trim(val.t);
+ }
+ }
+
+ // An error occurred with the selector;
+ // just return an empty set instead
+ if ( t )
+ ret = [];
+
+ // Remove the root context
+ if ( ret && context == ret[0] )
+ ret.shift();
+
+ // And combine the results
+ done = jQuery.merge( done, ret );
+
+ return done;
+ },
+
+ classFilter: function(r,m,not){
+ m = " " + m + " ";
+ var tmp = [];
+ for ( var i = 0; r[i]; i++ ) {
+ var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
+ if ( !not && pass || not && !pass )
+ tmp.push( r[i] );
+ }
+ return tmp;
+ },
+
+ filter: function(t,r,not) {
+ var last;
+
+ // Look for common filter expressions
+ while ( t && t != last ) {
+ last = t;
+
+ var p = jQuery.parse, m;
+
+ for ( var i = 0; p[i]; i++ ) {
+ m = p[i].exec( t );
+
+ if ( m ) {
+ // Remove what we just matched
+ t = t.substring( m[0].length );
+
+ m[2] = m[2].replace(/\\/g, "");
+ break;
+ }
+ }
+
+ if ( !m )
+ break;
+
+ // :not() is a special case that can be optimized by
+ // keeping it out of the expression list
+ if ( m[1] == ":" && m[2] == "not" )
+ // optimize if only one selector found (most common case)
+ r = isSimple.test( m[3] ) ?
+ jQuery.filter(m[3], r, true).r :
+ jQuery( r ).not( m[3] );
+
+ // We can get a big speed boost by filtering by class here
+ else if ( m[1] == "." )
+ r = jQuery.classFilter(r, m[2], not);
+
+ else if ( m[1] == "[" ) {
+ var tmp = [], type = m[3];
+
+ for ( var i = 0, rl = r.length; i < rl; i++ ) {
+ var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
+
+ if ( z == null || /href|src|selected/.test(m[2]) )
+ z = jQuery.attr(a,m[2]) || '';
+
+ if ( (type == "" && !!z ||
+ type == "=" && z == m[5] ||
+ type == "!=" && z != m[5] ||
+ type == "^=" && z && !z.indexOf(m[5]) ||
+ type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
+ (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
+ tmp.push( a );
+ }
+
+ r = tmp;
+
+ // We can get a speed boost by handling nth-child here
+ } else if ( m[1] == ":" && m[2] == "nth-child" ) {
+ var merge = {}, tmp = [],
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
+ !/\D/.test(m[3]) && "0n+" + m[3] || m[3]),
+ // calculate the numbers (first)n+(last) including if they are negative
+ first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0;
+
+ // loop through all the elements left in the jQuery object
+ for ( var i = 0, rl = r.length; i < rl; i++ ) {
+ var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
+
+ if ( !merge[id] ) {
+ var c = 1;
+
+ for ( var n = parentNode.firstChild; n; n = n.nextSibling )
+ if ( n.nodeType == 1 )
+ n.nodeIndex = c++;
+
+ merge[id] = true;
+ }
+
+ var add = false;
+
+ if ( first == 0 ) {
+ if ( node.nodeIndex == last )
+ add = true;
+ } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 )
+ add = true;
+
+ if ( add ^ not )
+ tmp.push( node );
+ }
+
+ r = tmp;
+
+ // Otherwise, find the expression to execute
+ } else {
+ var fn = jQuery.expr[ m[1] ];
+ if ( typeof fn == "object" )
+ fn = fn[ m[2] ];
+
+ if ( typeof fn == "string" )
+ fn = eval("false||function(a,i){return " + fn + ";}");
+
+ // Execute it against the current filter
+ r = jQuery.grep( r, function(elem, i){
+ return fn(elem, i, m, r);
+ }, not );
+ }
+ }
+
+ // Return an array of filtered elements (r)
+ // and the modified expression string (t)
+ return { r: r, t: t };
+ },
+
+ dir: function( elem, dir ){
+ var matched = [],
+ cur = elem[dir];
+ while ( cur && cur != document ) {
+ if ( cur.nodeType == 1 )
+ matched.push( cur );
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function(cur,result,dir,elem){
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] )
+ if ( cur.nodeType == 1 && ++num == result )
+ break;
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType == 1 && n != elem )
+ r.push( n );
+ }
+
+ return r;
+ }
+});
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code orignated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function(elem, types, handler, data) {
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return;
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( jQuery.browser.msie && elem.setInterval )
+ elem = window;
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid )
+ handler.guid = this.guid++;
+
+ // if data is passed, bind to handler
+ if( data != undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = this.proxy( fn, function() {
+ // Pass arguments and context to original handler
+ return fn.apply(this, arguments);
+ });
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
+ handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ if ( typeof jQuery != "undefined" && !jQuery.event.triggered )
+ return jQuery.event.handle.apply(arguments.callee.elem, arguments);
+ });
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type) {
+ // Namespaced event handlers
+ var parts = type.split(".");
+ type = parts[0];
+ handler.type = parts[1];
+
+ // Get the current list of functions bound to this event
+ var handlers = events[type];
+
+ // Init the event handler queue
+ if (!handlers) {
+ handlers = events[type] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
+ // Bind the global event handler to the element
+ if (elem.addEventListener)
+ elem.addEventListener(type, handle, false);
+ else if (elem.attachEvent)
+ elem.attachEvent("on" + type, handle);
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[handler.guid] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[type] = true;
+ });
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ guid: 1,
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function(elem, types, handler) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return;
+
+ var events = jQuery.data(elem, "events"), ret, index;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
+ for ( var type in events )
+ this.remove( elem, type + (types || "") );
+ else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events seperated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type){
+ // Namespaced event handlers
+ var parts = type.split(".");
+ type = parts[0];
+
+ if ( events[type] ) {
+ // remove the given handler for the given type
+ if ( handler )
+ delete events[type][handler.guid];
+
+ // remove all handlers for the given type
+ else
+ for ( handler in events[type] )
+ // Handle the removal of namespaced events
+ if ( !parts[1] || events[type][handler].type == parts[1] )
+ delete events[type][handler];
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[type] ) break;
+ if ( !ret ) {
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) {
+ if (elem.removeEventListener)
+ elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
+ else if (elem.detachEvent)
+ elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
+ }
+ ret = null;
+ delete events[type];
+ }
+ }
+ });
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) break;
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) handle.elem = null;
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ trigger: function(type, data, elem, donative, extra) {
+ // Clone the incoming data, if any
+ data = jQuery.makeArray(data);
+
+ if ( type.indexOf("!") >= 0 ) {
+ type = type.slice(0, -1);
+ var exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[type] )
+ jQuery("*").add([window, document]).trigger(type, data);
+
+ // Handle triggering a single element
+ } else {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return undefined;
+
+ var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
+ // Check to see if we need to provide a fake event, or not
+ event = !data[0] || !data[0].preventDefault;
+
+ // Pass along a fake event
+ if ( event ) {
+ data.unshift({
+ type: type,
+ target: elem,
+ preventDefault: function(){},
+ stopPropagation: function(){},
+ timeStamp: now()
+ });
+ data[0][expando] = true; // no need to fix fake event
+ }
+
+ // Enforce the right trigger type
+ data[0].type = type;
+ if ( exclusive )
+ data[0].exclusive = true;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data(elem, "handle");
+ if ( handle )
+ val = handle.apply( elem, data );
+
+ // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
+ if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
+ val = false;
+
+ // Extra functions don't get the custom event object
+ if ( event )
+ data.shift();
+
+ // Handle triggering of extra function
+ if ( extra && jQuery.isFunction( extra ) ) {
+ // call the extra function and tack the current return value on the end for possible inspection
+ ret = extra.apply( elem, val == null ? data : data.concat( val ) );
+ // if anything is returned, give it precedence and have it overwrite the previous value
+ if (ret !== undefined)
+ val = ret;
+ }
+
+ // Trigger the native events (except for clicks on links)
+ if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+ }
+
+ this.triggered = false;
+ }
+
+ return val;
+ },
+
+ handle: function(event) {
+ // returned undefined or false
+ var val, ret, namespace, all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+
+ // Namespaced event handlers
+ namespace = event.type.split(".");
+ event.type = namespace[0];
+ namespace = namespace[1];
+ // Cache this now, all = true means, any handler
+ all = !namespace && !event.exclusive;
+
+ handlers = ( jQuery.data(this, "events") || {} )[event.type];
+
+ for ( var j in handlers ) {
+ var handler = handlers[j];
+
+ // Filter the functions by class
+ if ( all || handler.type == namespace ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ ret = handler.apply( this, arguments );
+
+ if ( val !== false )
+ val = ret;
+
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+
+ return val;
+ },
+
+ fix: function(event) {
+ if ( event[expando] == true )
+ return event;
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = { originalEvent: originalEvent };
+ var props = "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");
+ for ( var i=props.length; i; i-- )
+ event[ props[i] ] = originalEvent[ props[i] ];
+
+ // Mark it as fixed
+ event[expando] = true;
+
+ // add preventDefault and stopPropagation since
+ // they will not work on the clone
+ event.preventDefault = function() {
+ // if preventDefault exists run it on the original event
+ if (originalEvent.preventDefault)
+ originalEvent.preventDefault();
+ // otherwise set the returnValue property of the original event to false (IE)
+ originalEvent.returnValue = false;
+ };
+ event.stopPropagation = function() {
+ // if stopPropagation exists run it on the original event
+ if (originalEvent.stopPropagation)
+ originalEvent.stopPropagation();
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ originalEvent.cancelBubble = true;
+ };
+
+ // Fix timeStamp
+ event.timeStamp = event.timeStamp || now();
+
+ // Fix target property, if necessary
+ if ( !event.target )
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType == 3 )
+ event.target = event.target.parentNode;
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement )
+ event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
+ event.which = event.charCode || event.keyCode;
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey )
+ event.metaKey = event.ctrlKey;
+
+ // Add which for click: 1 == left; 2 == middle; 3 == right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button )
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+
+ return event;
+ },
+
+ proxy: function( fn, proxy ){
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ special: {
+ ready: {
+ setup: function() {
+ // Make sure the ready event is setup
+ bindReady();
+ return;
+ },
+
+ teardown: function() { return; }
+ },
+
+ mouseenter: {
+ setup: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
+ return true;
+ },
+
+ teardown: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
+ return true;
+ },
+
+ handler: function(event) {
+ // If we actually just moused on to a sub-element, ignore it
+ if ( withinElement(event, this) ) return true;
+ // Execute the right handlers by setting the event type to mouseenter
+ event.type = "mouseenter";
+ return jQuery.event.handle.apply(this, arguments);
+ }
+ },
+
+ mouseleave: {
+ setup: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
+ return true;
+ },
+
+ teardown: function() {
+ if ( jQuery.browser.msie ) return false;
+ jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
+ return true;
+ },
+
+ handler: function(event) {
+ // If we actually just moused on to a sub-element, ignore it
+ if ( withinElement(event, this) ) return true;
+ // Execute the right handlers by setting the event type to mouseleave
+ event.type = "mouseleave";
+ return jQuery.event.handle.apply(this, arguments);
+ }
+ }
+ }
+};
+
+jQuery.fn.extend({
+ bind: function( type, data, fn ) {
+ return type == "unload" ? this.one(type, data, fn) : this.each(function(){
+ jQuery.event.add( this, type, fn || data, fn && data );
+ });
+ },
+
+ one: function( type, data, fn ) {
+ var one = jQuery.event.proxy( fn || data, function(event) {
+ jQuery(this).unbind(event, one);
+ return (fn || data).apply( this, arguments );
+ });
+ return this.each(function(){
+ jQuery.event.add( this, type, one, fn && data);
+ });
+ },
+
+ unbind: function( type, fn ) {
+ return this.each(function(){
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+
+ trigger: function( type, data, fn ) {
+ return this.each(function(){
+ jQuery.event.trigger( type, data, this, true, fn );
+ });
+ },
+
+ triggerHandler: function( type, data, fn ) {
+ return this[0] && jQuery.event.trigger( type, data, this[0], false, fn );
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while( i < args.length )
+ jQuery.event.proxy( fn, args[i++] );
+
+ return this.click( jQuery.event.proxy( fn, function(event) {
+ // Figure out which function to execute
+ this.lastToggle = ( this.lastToggle || 0 ) % i;
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ this.lastToggle++ ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function(fnOver, fnOut) {
+ return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut);
+ },
+
+ ready: function(fn) {
+ // Attach the listeners
+ bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady )
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ else
+ // Add the function to the wait list
+ jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
+
+ return this;
+ }
+});
+
+jQuery.extend({
+ isReady: false,
+ readyList: [],
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( jQuery.readyList ) {
+ // Execute all of them
+ jQuery.each( jQuery.readyList, function(){
+ this.call( document );
+ });
+
+ // Reset the list of functions
+ jQuery.readyList = null;
+ }
+
+ // Trigger any bound ready events
+ jQuery(document).triggerHandler("ready");
+ }
+ }
+});
+
+var readyBound = false;
+
+function bindReady(){
+ if ( readyBound ) return;
+ readyBound = true;
+
+ // Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
+ if ( document.addEventListener && !jQuery.browser.opera)
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
+
+ // If IE is used and is not in a frame
+ // Continually check to see if the document is ready
+ if ( jQuery.browser.msie && window == top ) (function(){
+ if (jQuery.isReady) return;
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ // and execute any waiting functions
+ jQuery.ready();
+ })();
+
+ if ( jQuery.browser.opera )
+ document.addEventListener( "DOMContentLoaded", function () {
+ if (jQuery.isReady) return;
+ for (var i = 0; i < document.styleSheets.length; i++)
+ if (document.styleSheets[i].disabled) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ // and execute any waiting functions
+ jQuery.ready();
+ }, false);
+
+ if ( jQuery.browser.safari ) {
+ var numStyles;
+ (function(){
+ if (jQuery.isReady) return;
+ if ( document.readyState != "loaded" && document.readyState != "complete" ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ if ( numStyles === undefined )
+ numStyles = jQuery("style, link[rel=stylesheet]").length;
+ if ( document.styleSheets.length != numStyles ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+ // and execute any waiting functions
+ jQuery.ready();
+ })();
+ }
+
+ // A fallback to window.onload, that will always work
+ jQuery.event.add( window, "load", jQuery.ready );
+}
+
+jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
+ "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
+ "submit,keydown,keypress,keyup,error").split(","), function(i, name){
+
+ // Handle event binding
+ jQuery.fn[name] = function(fn){
+ return fn ? this.bind(name, fn) : this.trigger(name);
+ };
+});
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function(event, elem) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+ // Traverse up the tree
+ while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
+ // Return true if we actually just moused on to a sub-element
+ return parent == elem;
+};
+
+// Prevent memory leaks in IE
+// And prevent errors on refresh with events like mouseover in other browsers
+// Window isn't included so as not to unbind existing unload events
+jQuery(window).bind("unload", function() {
+ jQuery("*").add(document).unbind();
+});
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url != 'string' )
+ return this._load( url );
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ callback = callback || function(){};
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params )
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else {
+ params = jQuery.param( params );
+ type = "POST";
+ }
+
+ var self = this;
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ complete: function(res, status){
+ // If successful, inject the HTML into all the matched elements
+ if ( status == "success" || status == "notmodified" )
+ // See if a selector was specified
+ self.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div/>")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+
+ self.each( callback, [res.responseText, status, res] );
+ }
+ });
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function(){
+ return jQuery.nodeName(this, "form") ?
+ jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function(){
+ return this.name && !this.disabled &&
+ (this.checked || /select|textarea/i.test(this.nodeName) ||
+ /text|hidden|password/i.test(this.type));
+ })
+ .map(function(i, elem){
+ var val = jQuery(this).val();
+ return val == null ? null :
+ val.constructor == Array ?
+ jQuery.map( val, function(val, i){
+ return {name: elem.name, value: val};
+ }) :
+ {name: elem.name, value: val};
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
+ jQuery.fn[o] = function(f){
+ return this.bind(o, f);
+ };
+});
+
+var jsc = now();
+
+jQuery.extend({
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was ommited
+ if ( jQuery.isFunction( data ) ) {
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ if ( jQuery.isFunction( data ) ) {
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ timeout: 0,
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ data: null,
+ username: null,
+ password: null,
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+
+ ajax: function( s ) {
+ // Extend the settings, but re-extend 's' so that it can be
+ // checked again later (in the test suite, specifically)
+ s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
+
+ var jsonp, jsre = /=\?(&|$)/g, status, data,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data != "string" )
+ s.data = jQuery.param(s.data);
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType == "jsonp" ) {
+ if ( type == "GET" ) {
+ if ( !s.url.match(jsre) )
+ s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ } else if ( !s.data || !s.data.match(jsre) )
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
+ jsonp = "jsonp" + jsc++;
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data )
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = function(tmp){
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+ try{ delete window[ jsonp ]; } catch(e){}
+ if ( head )
+ head.removeChild( script );
+ };
+ }
+
+ if ( s.dataType == "script" && s.cache == null )
+ s.cache = false;
+
+ if ( s.cache === false && type == "GET" ) {
+ var ts = now();
+ // try replacing _= if it is there
+ var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type == "GET" ) {
+ s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
+
+ // IE likes to send both get and post data, prevent this
+ s.data = null;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ )
+ jQuery.event.trigger( "ajaxStart" );
+
+ // Matches an absolute URL, and saves the domain
+ var remote = /^(?:\w+:)?\/\/([^\/?#]+)/;
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType == "script" && type == "GET"
+ && remote.test(s.url) && remote.exec(s.url)[1] != location.host ){
+ var head = document.getElementsByTagName("head")[0];
+ var script = document.createElement("script");
+ script.src = s.url;
+ if (s.scriptCharset)
+ script.charset = s.scriptCharset;
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function(){
+ if ( !done && (!this.readyState ||
+ this.readyState == "loaded" || this.readyState == "complete") ) {
+ done = true;
+ success();
+ complete();
+ head.removeChild( script );
+ }
+ };
+ }
+
+ head.appendChild(script);
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
+ var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if( s.username )
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ else
+ xhr.open(type, s.url, s.async);
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data )
+ xhr.setRequestHeader("Content-Type", s.contentType);
+
+ // Set the If-Modified-Since header, if ifModified mode.
+ if ( s.ifModified )
+ xhr.setRequestHeader("If-Modified-Since",
+ jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e){}
+
+ // Allow custom headers/mimetypes
+ if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
+ // cleanup active request counter
+ s.global && jQuery.active--;
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global )
+ jQuery.event.trigger("ajaxSend", [xhr, s]);
+
+ // Wait for a response to come back
+ var onreadystatechange = function(isTimeout){
+ // The transfer is complete and the data is available, or the request timed out
+ if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
+ requestDone = true;
+
+ // clear poll interval
+ if (ival) {
+ clearInterval(ival);
+ ival = null;
+ }
+
+ status = isTimeout == "timeout" && "timeout" ||
+ !jQuery.httpSuccess( xhr ) && "error" ||
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) && "notmodified" ||
+ "success";
+
+ if ( status == "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s.dataFilter );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status == "success" ) {
+ // Cache Last-Modified header, if ifModified mode.
+ var modRes;
+ try {
+ modRes = xhr.getResponseHeader("Last-Modified");
+ } catch(e) {} // swallow exception thrown by FF if header is not available
+
+ if ( s.ifModified && modRes )
+ jQuery.lastModified[s.url] = modRes;
+
+ // JSONP handles its own success callback
+ if ( !jsonp )
+ success();
+ } else
+ jQuery.handleError(s, xhr, status);
+
+ // Fire the complete handlers
+ complete();
+
+ // Stop memory leaks
+ if ( s.async )
+ xhr = null;
+ }
+ };
+
+ if ( s.async ) {
+ // don't attach the handler to the request, just poll it instead
+ var ival = setInterval(onreadystatechange, 13);
+
+ // Timeout checker
+ if ( s.timeout > 0 )
+ setTimeout(function(){
+ // Check to see if the request is still happening
+ if ( xhr ) {
+ // Cancel the request
+ xhr.abort();
+
+ if( !requestDone )
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send(s.data);
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async )
+ onreadystatechange();
+
+ function success(){
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success )
+ s.success( data, status );
+
+ // Fire the global callback
+ if ( s.global )
+ jQuery.event.trigger( "ajaxSuccess", [xhr, s] );
+ }
+
+ function complete(){
+ // Process result
+ if ( s.complete )
+ s.complete(xhr, status);
+
+ // The request was completed
+ if ( s.global )
+ jQuery.event.trigger( "ajaxComplete", [xhr, s] );
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) s.error( xhr, status, e );
+
+ // Fire the global callback
+ if ( s.global )
+ jQuery.event.trigger( "ajaxError", [xhr, s, e] );
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol == "file:" ||
+ ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 ||
+ jQuery.browser.safari && xhr.status == undefined;
+ } catch(e){}
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ try {
+ var xhrRes = xhr.getResponseHeader("Last-Modified");
+
+ // Firefox always returns 200. check Last-Modified date
+ return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
+ jQuery.browser.safari && xhr.status == undefined;
+ } catch(e){}
+ return false;
+ },
+
+ httpData: function( xhr, type, filter ) {
+ var ct = xhr.getResponseHeader("content-type"),
+ xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.tagName == "parsererror" )
+ throw "parsererror";
+
+ // Allow a pre-filtering function to sanitize the response
+ if( filter )
+ data = filter( data, type );
+
+ // If the type is "script", eval it in global context
+ if ( type == "script" )
+ jQuery.globalEval( data );
+
+ // Get the JavaScript object, if JSON is used.
+ if ( type == "json" )
+ data = eval("(" + data + ")");
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a ) {
+ var s = [];
+
+ // If an array was passed in, assume that it is an array
+ // of form elements
+ if ( a.constructor == Array || a.jquery )
+ // Serialize the form elements
+ jQuery.each( a, function(){
+ s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
+ });
+
+ // Otherwise, assume that it's an object of key/value pairs
+ else
+ // Serialize the key/values
+ for ( var j in a )
+ // If the value is an array then the key names need to be repeated
+ if ( a[j] && a[j].constructor == Array )
+ jQuery.each( a[j], function(){
+ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
+ });
+ else
+ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) );
+
+ // Return the resulting serialization
+ return s.join("&").replace(/%20/g, "+");
+ }
+
+});
+jQuery.fn.extend({
+ show: function(speed,callback){
+ return speed ?
+ this.animate({
+ height: "show", width: "show", opacity: "show"
+ }, speed, callback) :
+
+ this.filter(":hidden").each(function(){
+ this.style.display = this.oldblock || "";
+ if ( jQuery.css(this,"display") == "none" ) {
+ var elem = jQuery("<" + this.tagName + " />").appendTo("body");
+ this.style.display = elem.css("display");
+ // handle an edge condition where css is - div { display:none; } or similar
+ if (this.style.display == "none")
+ this.style.display = "block";
+ elem.remove();
+ }
+ }).end();
+ },
+
+ hide: function(speed,callback){
+ return speed ?
+ this.animate({
+ height: "hide", width: "hide", opacity: "hide"
+ }, speed, callback) :
+
+ this.filter(":visible").each(function(){
+ this.oldblock = this.oldblock || jQuery.css(this,"display");
+ this.style.display = "none";
+ }).end();
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ){
+ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
+ this._toggle.apply( this, arguments ) :
+ fn ?
+ this.animate({
+ height: "toggle", width: "toggle", opacity: "toggle"
+ }, fn, fn2) :
+ this.each(function(){
+ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
+ });
+ },
+
+ slideDown: function(speed,callback){
+ return this.animate({height: "show"}, speed, callback);
+ },
+
+ slideUp: function(speed,callback){
+ return this.animate({height: "hide"}, speed, callback);
+ },
+
+ slideToggle: function(speed, callback){
+ return this.animate({height: "toggle"}, speed, callback);
+ },
+
+ fadeIn: function(speed, callback){
+ return this.animate({opacity: "show"}, speed, callback);
+ },
+
+ fadeOut: function(speed, callback){
+ return this.animate({opacity: "hide"}, speed, callback);
+ },
+
+ fadeTo: function(speed,to,callback){
+ return this.animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ return this[ optall.queue === false ? "each" : "queue" ](function(){
+ if ( this.nodeType != 1)
+ return false;
+
+ var opt = jQuery.extend({}, optall), p,
+ hidden = jQuery(this).is(":hidden"), self = this;
+
+ for ( p in prop ) {
+ if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+ return opt.complete.call(this);
+
+ if ( p == "height" || p == "width" ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+ }
+
+ if ( opt.overflow != null )
+ this.style.overflow = "hidden";
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function(name, val){
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( /toggle|show|hide/.test(val) )
+ e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+ else {
+ var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat(parts[2]),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit != "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] )
+ end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
+
+ e.custom( start, end, unit );
+ } else
+ e.custom( start, val, "" );
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ queue: function(type, fn){
+ if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
+ fn = type;
+ type = "fx";
+ }
+
+ if ( !type || (typeof type == "string" && !fn) )
+ return queue( this[0], type );
+
+ return this.each(function(){
+ if ( fn.constructor == Array )
+ queue(this, type, fn);
+ else {
+ queue(this, type).push( fn );
+
+ if ( queue(this, type).length == 1 )
+ fn.call(this);
+ }
+ });
+ },
+
+ stop: function(clearQueue, gotoEnd){
+ var timers = jQuery.timers;
+
+ if (clearQueue)
+ this.queue([]);
+
+ this.each(function(){
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- )
+ if ( timers[i].elem == this ) {
+ if (gotoEnd)
+ // force the next step to be the last
+ timers[i](true);
+ timers.splice(i, 1);
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if (!gotoEnd)
+ this.dequeue();
+
+ return this;
+ }
+
+});
+
+var queue = function( elem, type, array ) {
+ if ( elem ){
+
+ type = type || "fx";
+
+ var q = jQuery.data( elem, type + "queue" );
+
+ if ( !q || array )
+ q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
+
+ }
+ return q;
+};
+
+jQuery.fn.dequeue = function(type){
+ type = type || "fx";
+
+ return this.each(function(){
+ var q = queue(this, type);
+
+ q.shift();
+
+ if ( q.length )
+ q[0].call( this );
+ });
+};
+
+jQuery.extend({
+
+ speed: function(speed, easing, fn) {
+ var opt = speed && speed.constructor == Object ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && easing.constructor != Function && easing
+ };
+
+ opt.duration = (opt.duration && opt.duration.constructor == Number ?
+ opt.duration :
+ jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function(){
+ if ( opt.queue !== false )
+ jQuery(this).dequeue();
+ if ( jQuery.isFunction( opt.old ) )
+ opt.old.call( this );
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+ timerId: null,
+
+ fx: function( elem, options, prop ){
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig )
+ options.orig = {};
+ }
+
+});
+
+jQuery.fx.prototype = {
+
+ // Simple function for setting a style value
+ update: function(){
+ if ( this.options.step )
+ this.options.step.call( this.elem, this.now, this );
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( this.prop == "height" || this.prop == "width" )
+ this.elem.style.display = "block";
+ },
+
+ // Get the current size
+ cur: function(force){
+ if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
+ return this.elem[ this.prop ];
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function(from, to, unit){
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+ this.update();
+
+ var self = this;
+ function t(gotoEnd){
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ jQuery.timers.push(t);
+
+ if ( jQuery.timerId == null ) {
+ jQuery.timerId = setInterval(function(){
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ )
+ if ( !timers[i]() )
+ timers.splice(i--, 1);
+
+ if ( !timers.length ) {
+ clearInterval( jQuery.timerId );
+ jQuery.timerId = null;
+ }
+ }, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function(){
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ this.custom(0, this.cur());
+
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ if ( this.prop == "width" || this.prop == "height" )
+ this.elem.style[this.prop] = "1px";
+
+ // Start by showing the element
+ jQuery(this.elem).show();
+ },
+
+ // Simple 'hide' function
+ hide: function(){
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function(gotoEnd){
+ var t = now();
+
+ if ( gotoEnd || t > this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ var done = true;
+ for ( var i in this.options.curAnim )
+ if ( this.options.curAnim[i] !== true )
+ done = false;
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ this.elem.style.display = this.options.display;
+ if ( jQuery.css(this.elem, "display") == "none" )
+ this.elem.style.display = "block";
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide )
+ this.elem.style.display = "none";
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show )
+ for ( var p in this.options.curAnim )
+ jQuery.attr(this.elem.style, p, this.options.orig[p]);
+ }
+
+ if ( done )
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+
+ return false;
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+
+};
+
+jQuery.extend( jQuery.fx, {
+ speeds:{
+ slow: 600,
+ fast: 200,
+ // Default speed
+ def: 400
+ },
+ step: {
+ scrollLeft: function(fx){
+ fx.elem.scrollLeft = fx.now;
+ },
+
+ scrollTop: function(fx){
+ fx.elem.scrollTop = fx.now;
+ },
+
+ opacity: function(fx){
+ jQuery.attr(fx.elem.style, "opacity", fx.now);
+ },
+
+ _default: function(fx){
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ }
+ }
+});
+// The Offset Method
+// Originally By Brandon Aaron, part of the Dimension Plugin
+// http://jquery.com/plugins/project/dimensions
+jQuery.fn.offset = function() {
+ var left = 0, top = 0, elem = this[0], results;
+
+ if ( elem ) with ( jQuery.browser ) {
+ var parent = elem.parentNode,
+ offsetChild = elem,
+ offsetParent = elem.offsetParent,
+ doc = elem.ownerDocument,
+ safari2 = safari && parseInt(version) < 522 && !/adobeair/i.test(userAgent),
+ css = jQuery.curCSS,
+ fixed = css(elem, "position") == "fixed";
+
+ // Use getBoundingClientRect if available
+ if ( elem.getBoundingClientRect ) {
+ var box = elem.getBoundingClientRect();
+
+ // Add the document scroll offsets
+ add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+ box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
+
+ // IE adds the HTML element's border, by default it is medium which is 2px
+ // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
+ // IE 7 standards mode, the border is always 2px
+ // This border/offset is typically represented by the clientLeft and clientTop properties
+ // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
+ // Therefore this method will be off by 2px in IE while in quirksmode
+ add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop );
+
+ // Otherwise loop through the offsetParents and parentNodes
+ } else {
+
+ // Initial element offsets
+ add( elem.offsetLeft, elem.offsetTop );
+
+ // Get parent offsets
+ while ( offsetParent ) {
+ // Add offsetParent offsets
+ add( offsetParent.offsetLeft, offsetParent.offsetTop );
+
+ // Mozilla and Safari > 2 does not include the border on offset parents
+ // However Mozilla adds the border for table or table cells
+ if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
+ border( offsetParent );
+
+ // Add the document scroll offsets if position is fixed on any offsetParent
+ if ( !fixed && css(offsetParent, "position") == "fixed" )
+ fixed = true;
+
+ // Set offsetChild to previous offsetParent unless it is the body element
+ offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
+ // Get next offsetParent
+ offsetParent = offsetParent.offsetParent;
+ }
+
+ // Get parent scroll offsets
+ while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
+ // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug
+ if ( !/^inline|table.*$/i.test(css(parent, "display")) )
+ // Subtract parent scroll offsets
+ add( -parent.scrollLeft, -parent.scrollTop );
+
+ // Mozilla does not add the border for a parent that has overflow != visible
+ if ( mozilla && css(parent, "overflow") != "visible" )
+ border( parent );
+
+ // Get next parent
+ parent = parent.parentNode;
+ }
+
+ // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
+ // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
+ if ( (safari2 && (fixed || css(offsetChild, "position") == "absolute")) ||
+ (mozilla && css(offsetChild, "position") != "absolute") )
+ add( -doc.body.offsetLeft, -doc.body.offsetTop );
+
+ // Add the document scroll offsets if position is fixed
+ if ( fixed )
+ add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
+ Math.max(doc.documentElement.scrollTop, doc.body.scrollTop));
+ }
+
+ // Return an object with top and left properties
+ results = { top: top, left: left };
+ }
+
+ function border(elem) {
+ add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) );
+ }
+
+ function add(l, t) {
+ left += parseInt(l, 10) || 0;
+ top += parseInt(t, 10) || 0;
+ }
+
+ return results;
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ var left = 0, top = 0, results;
+
+ if ( this[0] ) {
+ // Get *real* offsetParent
+ var offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= num( this, 'marginTop' );
+ offset.left -= num( this, 'marginLeft' );
+
+ // Add offsetParent borders
+ parentOffset.top += num( offsetParent, 'borderTopWidth' );
+ parentOffset.left += num( offsetParent, 'borderLeftWidth' );
+
+ // Subtract the two offsets
+ results = {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ }
+
+ return results;
+ },
+
+ offsetParent: function() {
+ var offsetParent = this[0].offsetParent;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
+ offsetParent = offsetParent.offsetParent;
+ return jQuery(offsetParent);
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ['Left', 'Top'], function(i, name) {
+ var method = 'scroll' + name;
+
+ jQuery.fn[ method ] = function(val) {
+ if (!this[0]) return;
+
+ return val != undefined ?
+
+ // Set the scroll offset
+ this.each(function() {
+ this == window || this == document ?
+ window.scrollTo(
+ !i ? val : jQuery(window).scrollLeft(),
+ i ? val : jQuery(window).scrollTop()
+ ) :
+ this[ method ] = val;
+ }) :
+
+ // Return the scroll offset
+ this[0] == window || this[0] == document ?
+ self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
+ jQuery.boxModel && document.documentElement[ method ] ||
+ document.body[ method ] :
+ this[0][ method ];
+ };
+});
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function(i, name){
+
+ var tl = i ? "Left" : "Top", // top or left
+ br = i ? "Right" : "Bottom"; // bottom or right
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function(){
+ return this[ name.toLowerCase() ]() +
+ num(this, "padding" + tl) +
+ num(this, "padding" + br);
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function(margin) {
+ return this["inner" + name]() +
+ num(this, "border" + tl + "Width") +
+ num(this, "border" + br + "Width") +
+ (margin ?
+ num(this, "margin" + tl) + num(this, "margin" + br) : 0);
+ };
+
+});})();
diff --git a/dom/tests/mochitest/ajax/jquery/manifest.json b/dom/tests/mochitest/ajax/jquery/manifest.json
new file mode 100644
index 0000000000..d33c00c7f1
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/manifest.json
@@ -0,0 +1 @@
+{testcases:["test/index.html"]}
diff --git a/dom/tests/mochitest/ajax/jquery/mochitest.ini b/dom/tests/mochitest/ajax/jquery/mochitest.ini
new file mode 100644
index 0000000000..3f10b1cf77
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/mochitest.ini
@@ -0,0 +1,37 @@
+[DEFAULT]
+support-files =
+ manifest.json
+ dist/jquery.js
+ test/index.html
+ test/offset.html
+ test/test.js
+ test/fix.html
+ test/data/cow.jpg
+ test/data/dashboard.xml
+ test/data/iframe.html
+ test/data/json_assigned_obj.js
+ test/data/json_obj.js
+ test/data/name.html
+ test/data/test.html
+ test/data/test.js
+ test/data/test2.html
+ test/data/test3.html
+ test/data/testrunner.js
+ test/data/testsuite.css
+ test/data/with_fries.xml
+ test/data/offset/absolute.html
+ test/data/offset/fixed.html
+ test/data/offset/relative.html
+ test/data/offset/scroll.html
+ test/data/offset/static.html
+ test/data/offset/table.html
+ test/unit/ajax.js
+ test/unit/core.js
+ test/unit/dimensions.js
+ test/unit/event.js
+ test/unit/fx.js
+ test/unit/offset.js
+ test/unit/selector.js
+
+[test_jQuery.html]
+skip-if = (os == "android") # Bug 1780219
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/cow.jpg b/dom/tests/mochitest/ajax/jquery/test/data/cow.jpg
new file mode 100644
index 0000000000..2c5b672259
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/cow.jpg
Binary files differ
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/dashboard.xml b/dom/tests/mochitest/ajax/jquery/test/data/dashboard.xml
new file mode 100644
index 0000000000..10f6b33479
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/dashboard.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dashboard>
+ <locations class="foo">
+ <location for="bar">
+ <infowindowtab>
+ <tab title="Location"><![CDATA[blabla]]></tab>
+ <tab title="Users"><![CDATA[blublu]]></tab>
+ </infowindowtab>
+ </location>
+ </locations>
+</dashboard>
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/iframe.html b/dom/tests/mochitest/ajax/jquery/test/data/iframe.html
new file mode 100644
index 0000000000..3ff26e1612
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/iframe.html
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>iframe</title>
+ </head>
+ <body>
+ <div><span>span text</span></div>
+ </body>
+</html>
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/json_assigned_obj.js b/dom/tests/mochitest/ajax/jquery/test/data/json_assigned_obj.js
new file mode 100644
index 0000000000..867251dad1
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/json_assigned_obj.js
@@ -0,0 +1 @@
+json_assigned_obj = { "test" : "worked" };
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/json_obj.js b/dom/tests/mochitest/ajax/jquery/test/data/json_obj.js
new file mode 100644
index 0000000000..7fa61820f8
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/json_obj.js
@@ -0,0 +1 @@
+{ "data": {"lang": "en", "length": 25} }
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/name.html b/dom/tests/mochitest/ajax/jquery/test/data/name.html
new file mode 100644
index 0000000000..0fa32d1a82
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/name.html
@@ -0,0 +1 @@
+ERROR <script type="text/javascript">ok( true, "name.html retrieved" );</script>
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/offset/absolute.html b/dom/tests/mochitest/ajax/jquery/test/data/offset/absolute.html
new file mode 100644
index 0000000000..3bbc8417dc
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/offset/absolute.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>absolute</title>
+ <style type="text/css" media="screen">
+ body { margin: 1px; padding: 5px; }
+ div.absolute { position: absolute; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; }
+ #absolute-1 { top: 0; left: 0; }
+ #absolute-1-1 { top: 1px; left: 1px; }
+ #absolute-1-1-1 { top: 1px; left: 1px; }
+ #absolute-2 { top: 19px; left: 19px; }
+ #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
+ p.instructions { position: absolute; bottom: 0; }
+ </style>
+ <script type="text/javascript" src="../../../dist/jquery.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(function() {
+ $('.absolute').click(function() {
+ $('#marker').css( $(this).offset() );
+ var pos = $(this).position();
+ $(this).css({ top: pos.top, left: pos.left });
+ return false;
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <div id="absolute-1" class="absolute">absolute-1
+ <div id="absolute-1-1" class="absolute">absolute-1-1
+ <div id="absolute-1-1-1" class="absolute">absolute-1-1-1</div>
+ </div>
+ </div>
+ <div id="absolute-2" class="absolute">absolute-2</div>
+ <div id="marker"></div>
+ <p class="instructions">Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/offset/fixed.html b/dom/tests/mochitest/ajax/jquery/test/data/offset/fixed.html
new file mode 100644
index 0000000000..8d69aae94d
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/offset/fixed.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>fixed</title>
+ <style type="text/css" media="screen">
+ body { margin: 1px; padding: 5px; }
+ div.fixed { position: fixed; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; overflow: hidden; }
+ #fixed-1 { top: 0; left: 0; }
+ #fixed-2 { top: 20px; left: 20px; }
+ #forceScroll { width: 5000px; height: 5000px; }
+ #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
+ </style>
+ <script type="text/javascript" src="../../../dist/jquery.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(function() {
+ window.scrollTo(1000,1000);
+ $('.fixed').click(function() {
+ $('#marker').css( $(this).offset() );
+ return false;
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <div id="fixed-1" class="fixed"></div>
+ <div id="fixed-2" class="fixed"></div>
+ <div id="forceScroll"></div>
+ <div id="marker"></div>
+ <p class="instructions">Click the white box to move the marker to it.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/offset/relative.html b/dom/tests/mochitest/ajax/jquery/test/data/offset/relative.html
new file mode 100644
index 0000000000..89aae83e4a
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/offset/relative.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>relative</title>
+ <style type="text/css" media="screen">
+ body { margin: 1px; padding: 5px; }
+ div.relative { position: relative; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; overflow: hidden; }
+ #relative-2 { top: 20px; left: 20px; }
+ #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
+ </style>
+ <script type="text/javascript" src="../../../dist/jquery.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(function() {
+ $('.relative').click(function() {
+ $('#marker').css( $(this).offset() );
+ var pos = $(this).position();
+ $(this).css({ position: 'absolute', top: pos.top, left: pos.left });
+ return false;
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <div id="relative-1" class="relative"><div id="relative-1-1" class="relative"><div id="relative-1-1-1" class="relative"></div></div></div>
+ <div id="relative-2" class="relative"></div>
+ <div id="marker"></div>
+ <p class="instructions">Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/offset/scroll.html b/dom/tests/mochitest/ajax/jquery/test/data/offset/scroll.html
new file mode 100644
index 0000000000..494f640581
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/offset/scroll.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>scroll</title>
+ <style type="text/css" media="screen">
+ body { margin: 1px; padding: 5px; }
+ div.scroll { position: relative; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; overflow: auto; }
+ #scroll-1 { top: 0; left: 0; }
+ #scroll-1-1 { top: 1px; left: 1px; }
+ #scroll-1-1-1 { top: 1px; left: 1px; }
+ #forceScroll { width: 5000px; height: 5000px; }
+ #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
+ </style>
+ <script type="text/javascript" src="../../../dist/jquery.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(function() {
+ window.scrollTo(1000,1000);
+ $('#scroll-1')[0].scrollLeft = 5;
+ $('#scroll-1')[0].scrollTop = 5;
+ $('.scroll').click(function() {
+ $('#marker').css( $(this).offset() );
+ return false;
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <div id="scroll-1" class="scroll">
+ <div id="scroll-1-1" class="scroll">
+ <div id="scroll-1-1-1" class="scroll"></div>
+ </div>
+ </div>
+ <div id="forceScroll"></div>
+ <div id="marker"></div>
+ <p class="instructions">Click the white box to move the marker to it.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/offset/static.html b/dom/tests/mochitest/ajax/jquery/test/data/offset/static.html
new file mode 100644
index 0000000000..10116af65b
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/offset/static.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>static</title>
+ <style type="text/css" media="screen">
+ body { margin: 1px; padding: 5px; }
+ div.static { position: static; margin: 1px; border: 2px solid #000; padding: 5px; width: 100px; height: 100px; background: #fff; overflow: hidden; }
+ #static-2 { top: 20px; left: 20px; }
+ #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
+ </style>
+ <script type="text/javascript" src="../../../dist/jquery.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(function() {
+ $('.static').click(function() {
+ $('#marker').css( $(this).offset() );
+ var pos = $(this).position();
+ $(this).css({ position: 'absolute', top: pos.top, left: pos.left });
+ return false;
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <div id="static-1" class="static"><div id="static-1-1" class="static"><div id="static-1-1-1" class="static"></div></div></div>
+ <div id="static-2" class="static"></div>
+ <div id="marker"></div>
+ <p class="instructions">Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/offset/table.html b/dom/tests/mochitest/ajax/jquery/test/data/offset/table.html
new file mode 100644
index 0000000000..5d15b903b6
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/offset/table.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>table</title>
+ <style type="text/css" media="screen">
+ body { margin: 1px; padding: 5px; }
+ table { border: 2px solid #000; }
+ th, td { border: 1px solid #000; width: 100px; height: 100px; }
+ #marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
+ </style>
+ <script type="text/javascript" src="../../../dist/jquery.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(function() {
+ $('table, th, td').click(function() {
+ $('#marker').css( $(this).offset() );
+ return false;
+ });
+ });
+ </script>
+ </head>
+ <body>
+ <table id="table-1">
+ <thead>
+ <tr valign="top">
+ <th id="th-1">th-1</th>
+ <th id="th-2">th-2</th>
+ <th id="th-3">th-3</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr valign="top">
+ <td id="td-1">td-1</td>
+ <td id="td-2">td-2</td>
+ <td id="td-3">td-3</td>
+ </tr>
+ </tbody>
+ </table>
+ <div id="marker"></div>
+ <p class="instructions">Click the white box to move the marker to it.</p>
+ </body>
+</html> \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/test.html b/dom/tests/mochitest/ajax/jquery/test/data/test.html
new file mode 100644
index 0000000000..fc6dc38607
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/test.html
@@ -0,0 +1,7 @@
+html text<br/>
+<script type="text/javascript">/* <![CDATA[ */
+testFoo = "foo"; $('#foo').html('foo');
+ok( true, "test.html executed" );
+/* ]]> */</script>
+<script src="data/test.js"></script>
+blabla
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/test.js b/dom/tests/mochitest/ajax/jquery/test/data/test.js
new file mode 100644
index 0000000000..f8bdd091e4
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/test.js
@@ -0,0 +1,3 @@
+var foobar = "bar";
+$('#ap').html('bar');
+ok( true, "test.js executed");
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/test2.html b/dom/tests/mochitest/ajax/jquery/test/data/test2.html
new file mode 100644
index 0000000000..ebf610e438
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/test2.html
@@ -0,0 +1,5 @@
+<script type="text/javascript">
+var testFoo = "foo";
+$('#foo').html('foo');
+ok( true, "test2.html executed" );
+</script>
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/test3.html b/dom/tests/mochitest/ajax/jquery/test/data/test3.html
new file mode 100644
index 0000000000..909d41745c
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/test3.html
@@ -0,0 +1,3 @@
+<div class="user">This is a user</div>
+<div class="user">This is a user</div>
+<div class="teacher">This is a teacher</div>
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/testrunner.js b/dom/tests/mochitest/ajax/jquery/test/data/testrunner.js
new file mode 100644
index 0000000000..24bf0a863a
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/testrunner.js
@@ -0,0 +1,334 @@
+var _config = {
+ fixture: null,
+ Test: [],
+ stats: {
+ all: 0,
+ bad: 0
+ },
+ queue: [],
+ blocking: true,
+ timeout: null,
+ expected: null,
+ currentModule: null,
+ asyncTimeout: 2 // seconds for async timeout
+};
+
+_config.filters = location.search.length > 1 && //restrict modules/tests by get parameters
+ $.map( location.search.slice(1).split('&'), decodeURIComponent );
+
+var isLocal = !!(window.location.protocol == 'file:');
+
+$(function() {
+ $('#userAgent').html(navigator.userAgent);
+ runTest();
+});
+
+function synchronize(callback) {
+ _config.queue[_config.queue.length] = callback;
+ if(!_config.blocking) {
+ process();
+ }
+}
+
+function process() {
+ while(_config.queue.length && !_config.blocking) {
+ var call = _config.queue[0];
+ _config.queue = _config.queue.slice(1);
+ call();
+ }
+}
+
+function stop(allowFailure) {
+ _config.blocking = true;
+ var handler = allowFailure ? start : function() {
+ ok( false, "Test timed out" );
+ start();
+ };
+ // Disabled, caused too many random errors
+ //_config.timeout = setTimeout(handler, _config.asyncTimeout * 1000);
+}
+function start() {
+ // A slight delay, to avoid any current callbacks
+ setTimeout(function(){
+ if(_config.timeout)
+ clearTimeout(_config.timeout);
+ _config.blocking = false;
+ process();
+ }, 13);
+}
+
+function validTest( name ) {
+ var filters = _config.filters;
+ if( !filters )
+ return true;
+
+ var i = filters.length,
+ run = false;
+ while( i-- ){
+ var filter = filters[i],
+ not = filter.charAt(0) == '!';
+ if( not )
+ filter = filter.slice(1);
+ if( name.indexOf(filter) != -1 )
+ return !not;
+ if( not )
+ run = true;
+ }
+ return run;
+}
+
+function runTest() {
+ _config.blocking = false;
+ var time = new Date();
+ _config.fixture = document.getElementById('main').innerHTML;
+ _config.ajaxSettings = $.ajaxSettings;
+ synchronize(function() {
+ time = new Date() - time;
+ $("<div>").html(['<p class="result">Tests completed in ',
+ time, ' milliseconds.<br/>',
+ _config.stats.bad, ' tests of ', _config.stats.all, ' failed.</p>']
+ .join(''))
+ .appendTo("body");
+ $("#banner").addClass(_config.stats.bad ? "fail" : "pass");
+ if ( parent.runAJAXTest )
+ parent.runAJAXTest();
+
+ });
+}
+
+function test(name, callback, nowait) {
+ if(_config.currentModule)
+ name = _config.currentModule + " module: " + name;
+
+ if ( !validTest(name) )
+ return;
+
+ synchronize(function() {
+ _config.Test = [];
+ try {
+ callback();
+ } catch(e) {
+ if( typeof console != "undefined" && console.error && console.warn ) {
+ console.error("Test " + name + " died, exception and test follows");
+ console.error(e);
+ console.warn(callback.toString());
+ }
+ _config.Test.push( [ false, "Died on test #" + (_config.Test.length+1) + ": " + e.message ] );
+ }
+ });
+ synchronize(function() {
+ reset();
+
+ // don't output pause tests
+ if(nowait) return;
+
+ if(_config.expected && _config.expected != _config.Test.length) {
+ _config.Test.push( [ false, "Expected " + _config.expected + " assertions, but " + _config.Test.length + " were run" ] );
+ }
+ _config.expected = null;
+
+ var good = 0, bad = 0;
+ var ol = document.createElement("ol");
+ ol.style.display = "none";
+ var li = "", state = "pass";
+ for ( var i = 0; i < _config.Test.length; i++ ) {
+ var li = document.createElement("li");
+ li.className = _config.Test[i][0] ? "pass" : "fail";
+ li.innerHTML = _config.Test[i][1];
+ ol.appendChild( li );
+
+ _config.stats.all++;
+ if ( !_config.Test[i][0] ) {
+ state = "fail";
+ bad++;
+ _config.stats.bad++;
+ } else good++;
+
+ if ( parent.SimpleTest ){
+ parent.SimpleTest.ok( _config.Test[i][0], `${name}: ${_config.Test[i][1]}` );}
+ }
+
+ var li = document.createElement("li");
+ li.className = state;
+
+ var b = document.createElement("strong");
+ b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + _config.Test.length + ")</b>";
+ b.onclick = function(){
+ var n = this.nextSibling;
+ if ( jQuery.css( n, "display" ) == "none" )
+ n.style.display = "block";
+ else
+ n.style.display = "none";
+ };
+ $(b).dblclick(function(event) {
+ var target = jQuery(event.target).filter("strong").clone();
+ if ( target.length ) {
+ target.children().remove();
+ location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text()));
+ }
+ });
+ li.appendChild( b );
+ li.appendChild( ol );
+
+ document.getElementById("tests").appendChild( li );
+ });
+}
+
+// call on start of module test to prepend name to all tests
+function module(moduleName) {
+ _config.currentModule = moduleName;
+}
+
+/**
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
+ */
+function expect(asserts) {
+ _config.expected = asserts;
+}
+
+/**
+ * Resets the test setup. Useful for tests that modify the DOM.
+ */
+function reset() {
+ $("#main").html( _config.fixture );
+ $.event.global = {};
+ $.ajaxSettings = $.extend({}, _config.ajaxSettings);
+}
+
+/**
+ * Asserts true.
+ * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
+ */
+function ok(a, msg) {
+ _config.Test.push( [ !!a, msg ] );
+}
+
+/**
+ * Asserts that two arrays are the same
+ */
+function isSet(a, b, msg) {
+ var ret = true;
+ if ( a && b && a.length != undefined && a.length == b.length ) {
+ for ( var i = 0; i < a.length; i++ )
+ if ( a[i] != b[i] )
+ ret = false;
+ } else
+ ret = false;
+ if ( !ret )
+ _config.Test.push( [ ret, msg + " expected: " + serialArray(b) + " result: " + serialArray(a) ] );
+ else
+ _config.Test.push( [ ret, msg ] );
+}
+
+/**
+ * Asserts that two objects are equivalent
+ */
+function isObj(a, b, msg) {
+ var ret = true;
+
+ if ( a && b ) {
+ for ( var i in a )
+ if ( a[i] != b[i] )
+ ret = false;
+
+ for ( i in b )
+ if ( a[i] != b[i] )
+ ret = false;
+ } else
+ ret = false;
+
+ _config.Test.push( [ ret, msg ] );
+}
+
+function serialArray( a ) {
+ var r = [];
+
+ if ( a && a.length )
+ for ( var i = 0; i < a.length; i++ ) {
+ var str = a[i].nodeName;
+ if ( str ) {
+ str = str.toLowerCase();
+ if ( a[i].id )
+ str += "#" + a[i].id;
+ } else
+ str = a[i];
+ r.push( str );
+ }
+
+ return "[ " + r.join(", ") + " ]";
+}
+
+/**
+ * Returns an array of elements with the given IDs, eg.
+ * @example q("main", "foo", "bar")
+ * @result [<div id="main">, <span id="foo">, <input id="bar">]
+ */
+function q() {
+ var r = [];
+ for ( var i = 0; i < arguments.length; i++ )
+ r.push( document.getElementById( arguments[i] ) );
+ return r;
+}
+
+/**
+ * Asserts that a select matches the given IDs
+ * @example t("Check for something", "//[a]", ["foo", "baar"]);
+ * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
+ */
+function t(a,b,c) {
+ var f = jQuery(b);
+ var s = "";
+ for ( var i = 0; i < f.length; i++ )
+ s += (s && ",") + '"' + f[i].id + '"';
+ isSet(f, q.apply(q,c), a + " (" + b + ")");
+}
+
+/**
+ * Add random number to url to stop IE from caching
+ *
+ * @example url("data/test.html")
+ * @result "data/test.html?10538358428943"
+ *
+ * @example url("data/test.php?foo=bar")
+ * @result "data/test.php?foo=bar&10538358345554"
+ */
+function url(value) {
+ return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
+}
+
+/**
+ * Checks that the first two arguments are equal, with an optional message.
+ * Prints out both expected and actual values on failure.
+ *
+ * Prefered to ok( expected == actual, message )
+ *
+ * @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) );
+ *
+ * @param Object actual
+ * @param Object expected
+ * @param String message (optional)
+ */
+function equals(actual, expected, message) {
+ var result = expected == actual;
+ message = message || (result ? "okay" : "failed");
+ _config.Test.push( [ result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual ] );
+}
+
+/**
+ * Trigger an event on an element.
+ *
+ * @example triggerEvent( document.body, "click" );
+ *
+ * @param DOMElement elem
+ * @param String type
+ */
+function triggerEvent( elem, type, event ) {
+ if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
+ event = document.createEvent("MouseEvents");
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+ elem.dispatchEvent( event );
+ } else if ( jQuery.browser.msie ) {
+ elem.fireEvent("on"+type);
+ }
+} \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/testsuite.css b/dom/tests/mochitest/ajax/jquery/test/data/testsuite.css
new file mode 100644
index 0000000000..4801becd65
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/testsuite.css
@@ -0,0 +1,117 @@
+body, div, h1 { font-family: 'trebuchet ms', verdana, arial; margin: 0; padding: 0 }
+body {font-size: 10pt; }
+h1 { padding: 15px; font-size: large; background-color: #06b; color: white; }
+h2 { padding: 10px; background-color: #eee; color: black; margin: 0; font-size: small; font-weight: normal }
+
+.pass { color: green; }
+.fail { color: red; }
+p.result { margin-left: 1em; }
+
+#banner { height: 2em; border-bottom: 1px solid white; }
+h2.pass { background-color: green; }
+h2.fail { background-color: red; }
+
+ol#tests > li > strong { cursor:pointer; }
+
+div#fx-tests h4 {
+ background: red;
+}
+
+div#fx-tests h4.pass {
+ background: green;
+}
+
+div#fx-tests div.box {
+ background: red url(data/cow.jpg) no-repeat;
+ overflow: hidden;
+ border: 2px solid #000;
+}
+
+div#fx-tests div.overflow {
+ overflow: visible;
+}
+
+div.inline {
+ display: inline;
+}
+
+div.autoheight {
+ height: auto;
+}
+
+div.autowidth {
+ width: auto;
+}
+
+div.autoopacity {
+ opacity: auto;
+}
+
+div.largewidth {
+ width: 100px;
+}
+
+div.largeheight {
+ height: 100px;
+}
+
+div.largeopacity {
+ filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
+}
+
+div.medwidth {
+ width: 50px;
+}
+
+div.medheight {
+ height: 50px;
+}
+
+div.medopacity {
+ opacity: 0.5;
+ filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
+}
+
+div.nowidth {
+ width: 0px;
+}
+
+div.noheight {
+ height: 0px;
+}
+
+div.noopacity {
+ opacity: 0;
+ filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
+}
+
+div.hidden {
+ display: none;
+}
+
+div#fx-tests div.widewidth {
+ background-repeat: repeat-x;
+}
+
+div#fx-tests div.wideheight {
+ background-repeat: repeat-y;
+}
+
+div#fx-tests div.widewidth.wideheight {
+ background-repeat: repeat;
+}
+
+div#fx-tests div.noback {
+ background-image: none;
+}
+
+div.chain, div.chain div { width: 100px; height: 20px; position: relative; float: left; }
+div.chain div { position: absolute; top: 0px; left: 0px; }
+
+div.chain.test { background: red; }
+div.chain.test div { background: green; }
+
+div.chain.out { background: green; }
+div.chain.out div { background: red; display: none; }
+
+div#show-tests * { display: none; } \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/data/with_fries.xml b/dom/tests/mochitest/ajax/jquery/test/data/with_fries.xml
new file mode 100644
index 0000000000..88e0e49d57
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/data/with_fries.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <soap:Body>
+ <jsconf xmlns="http://www.example.com/ns1">
+ <response xmlns:ab="http://www.example.com/ns2">
+ <meta>
+ <component id="seite1">
+ <properties xmlns:cd="http://www.example.com/ns3">
+ <property name="prop1">
+ <thing />
+ <value>1</value>
+ </property>
+ <property name="prop2">
+ <thing att="something" />
+ </property>
+ <foo_bar>foo</foo_bar>
+ </properties>
+ </component>
+ </meta>
+ </response>
+ </jsconf>
+ </soap:Body>
+</soap:Envelope>
diff --git a/dom/tests/mochitest/ajax/jquery/test/fix.html b/dom/tests/mochitest/ajax/jquery/test/fix.html
new file mode 100644
index 0000000000..f4edab7919
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/fix.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta name="generator"
+ content="HTML Tidy, see www.w3.org" />
+
+ <title>Tester</title>
+<style type="text/css">
+ #container { background:yellow; width:400px; height:400px; }
+
+</style>
+<script type="text/javascript" src="../dist/jquery.js">
+</script>
+<script type="text/javascript">
+ function doIt() {
+ $("#adiv").text("click!");
+ $("#adiv").trigger("acustom.atype");
+ }
+
+ function showMouse(e) {
+ $("#adiv").text("( " + e.pageX + ", " + e.pageY + " )");
+ }
+
+ $(function () {
+ $("#doit").bind('click.mine', doIt);
+ $("#container").mousemove(showMouse);
+ $("#adiv").bind("acustom.atype", function () {
+ //console.log("custom");
+ });
+ });
+
+</script>
+ </head>
+
+ <body>
+ <button id="doit">Do It</button>
+
+ <div id="container">
+ Hi
+ </div>
+
+ <div id="adiv">
+ </div>
+ </body>
+</html>
+
diff --git a/dom/tests/mochitest/ajax/jquery/test/index.html b/dom/tests/mochitest/ajax/jquery/test/index.html
new file mode 100644
index 0000000000..8608f430b5
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/index.html
@@ -0,0 +1,187 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>jQuery Test Suite</title>
+ <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
+ <script>var jQuery = "jQuery", $ = "$"; // For testing .noConflict()</script>
+ <script type="text/javascript" src="../dist/jquery.js"></script>
+ <script type="text/javascript" src="data/testrunner.js"></script>
+ <script type="text/javascript" src="unit/core.js"></script>
+ <script type="text/javascript" src="unit/dimensions.js"></script>
+ <script type="text/javascript" src="unit/selector.js"></script>
+ <script type="text/javascript" src="unit/event.js"></script>
+ <script type="text/javascript" src="unit/ajax.js"></script>
+ <script type="text/javascript" src="unit/fx.js"></script>
+</head>
+
+<body id="body">
+ <h1 id="header">jQuery Test Suite</h1>
+ <h2 id="banner"></h2>
+ <h2 id="userAgent"></h2>
+
+ <!-- Test HTML -->
+ <div id="nothiddendiv" style="height:1px;background:white;">
+ <div id="nothiddendivchild"></div>
+ </div>
+ <!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
+ <iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
+ <dl id="dl" style="display:none;">
+ <div id="main" style="display: none;">
+ <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
+ <p id="ap">
+ Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
+ <a id="groups" href="http://groups.google.com/">Google Groups</a>.
+ This link has <code><a href="http://smin" id="anchor1">class="blog"</a></code>:
+ <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a>
+
+ </p>
+ <div id="foo">
+ <p id="sndp">Everything inside the red border is inside a div with <code>id="foo"</code>.</p>
+ <p lang="en" id="en">This is a normal link: <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p>
+ <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
+
+ </div>
+ <p id="first">Try them out:</p>
+ <ul id="firstUL"></ul>
+ <ol id="empty"></ol>
+ <form id="form" action="formaction">
+ <input type="text" name="action" value="Test" id="text1" minlength="20" maxlength="30"/>
+ <input type="text" name="text2" value="Test" id="text2" disabled="disabled"/>
+ <input type="radio" name="radio1" id="radio1" value="on"/>
+
+ <input type="radio" name="radio2" id="radio2" checked="checked"/>
+ <input type="checkbox" name="check" id="check1" checked="checked"/>
+ <input type="checkbox" id="check2" value="on"/>
+
+ <input type="hidden" name="hidden" id="hidden1"/>
+ <input type="text" style="display:none;" name="foo[bar]" id="hidden2"/>
+
+ <input type="text" id="name" name="name" value="name" />
+
+ <button id="button" name="button">Button</button>
+
+ <textarea id="area1" minlength="20" maxlength="30">foobar</textarea>
+
+ <select name="select1" id="select1">
+ <option id="option1a" class="emptyopt" value="">Nothing</option>
+ <option id="option1b" value="1">1</option>
+ <option id="option1c" value="2">2</option>
+ <option id="option1d" value="3">3</option>
+ </select>
+ <select name="select2" id="select2">
+ <option id="option2a" class="emptyopt" value="">Nothing</option>
+ <option id="option2b" value="1">1</option>
+ <option id="option2c" value="2">2</option>
+ <option id="option2d" selected="selected" value="3">3</option>
+ </select>
+ <select name="select3" id="select3" multiple="multiple">
+ <option id="option3a" class="emptyopt" value="">Nothing</option>
+ <option id="option3b" selected="selected" value="1">1</option>
+ <option id="option3c" selected="selected" value="2">2</option>
+ <option id="option3d" value="3">3</option>
+ </select>
+
+ <object id="object1" codebase="stupid">
+ <param name="p1" value="x1" />
+ <param name="p2" value="x2" />
+ </object>
+
+ <span id="台北Táiběi"></span>
+ <span id="台北" lang="中文"></span>
+ <span id="utf8class1" class="台北Táiběi 台北"></span>
+ <span id="utf8class2" class="台北"></span>
+ <span id="foo:bar" class="foo:bar"></span>
+ <span id="test.foo[5]bar" class="test.foo[5]bar"></span>
+
+ <foo_bar id="foobar">test element</foo_bar>
+ </form>
+ <b id="floatTest">Float test.</b>
+ <iframe id="iframe" name="iframe"></iframe>
+ <form id="lengthtest">
+ <input type="text" id="length" name="test"/>
+ <input type="text" id="idTest" name="id"/>
+ </form>
+ <table id="table"></table>
+
+ <div id="fx-queue">
+ <div id="fadein" class='chain test'>fadeIn<div>fadeIn</div></div>
+ <div id="fadeout" class='chain test out'>fadeOut<div>fadeOut</div></div>
+
+ <div id="show" class='chain test'>show<div>show</div></div>
+ <div id="hide" class='chain test out'>hide<div>hide</div></div>
+
+ <div id="togglein" class='chain test'>togglein<div>togglein</div></div>
+ <div id="toggleout" class='chain test out'>toggleout<div>toggleout</div></div>
+
+
+ <div id="slideup" class='chain test'>slideUp<div>slideUp</div></div>
+ <div id="slidedown" class='chain test out'>slideDown<div>slideDown</div></div>
+
+ <div id="slidetogglein" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>
+ <div id="slidetoggleout" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>
+ </div>
+
+ <div id="fx-tests"></div>
+
+ <form id="testForm" action="#" method="get">
+ <textarea name="T3" rows="2" cols="15">?
+Z</textarea>
+ <input type="hidden" name="H1" value="x" />
+ <input type="hidden" name="H2" />
+ <input name="PWD" type="password" value="" />
+ <input name="T1" type="text" />
+ <input name="T2" type="text" value="YES" readonly="readonly" />
+ <input type="checkbox" name="C1" value="1" />
+ <input type="checkbox" name="C2" />
+ <input type="radio" name="R1" value="1" />
+ <input type="radio" name="R1" value="2" />
+ <input type="text" name="My Name" value="me" />
+ <input type="reset" name="reset" value="NO" />
+ <select name="S1">
+ <option value="abc">ABC</option>
+ <option value="abc">ABC</option>
+ <option value="abc">ABC</option>
+ </select>
+ <select name="S2" multiple="multiple" size="3">
+ <option value="abc">ABC</option>
+ <option value="abc">ABC</option>
+ <option value="abc">ABC</option>
+ </select>
+ <select name="S3">
+ <option selected="selected">YES</option>
+ </select>
+ <select name="S4">
+ <option value="" selected="selected">NO</option>
+ </select>
+ <input type="submit" name="sub1" value="NO" />
+ <input type="submit" name="sub2" value="NO" />
+ <input type="image" name="sub3" value="NO" />
+ <button name="sub4" type="submit" value="NO">NO</button>
+ <input name="D1" type="text" value="NO" disabled="disabled" />
+ <input type="checkbox" checked="checked" disabled="disabled" name="D2" value="NO" />
+ <input type="radio" name="D3" value="NO" checked="checked" disabled="disabled" />
+ <select name="D4" disabled="disabled">
+ <option selected="selected" value="NO">NO</option>
+ </select>
+ </form>
+ <div id="moretests">
+ <form>
+ <div id="checkedtest" style="display:none;">
+ <input type="radio" name="checkedtestradios" checked="checked"/>
+ <input type="radio" name="checkedtestradios" value="on"/>
+ <input type="checkbox" name="checkedtestcheckboxes" checked="checked"/>
+ <input type="checkbox" name="checkedtestcheckboxes" />
+ </div>
+ </form>
+ <div id="nonnodes"><span>hi</span> there <!-- mon ami --></div>
+ <div id="t2037">
+ <div><div class="hidden">hidden</div></div>
+ </div>
+ </div>
+ </div>
+ </dl>
+
+ <ol id="tests"></ol>
+</body>
+</html>
diff --git a/dom/tests/mochitest/ajax/jquery/test/offset.html b/dom/tests/mochitest/ajax/jquery/test/offset.html
new file mode 100644
index 0000000000..f802dea346
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/offset.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>jQuery Offset Test Suite</title>
+ <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
+ <script type="text/javascript" src="../dist/jquery.js"></script>
+ <script type="text/javascript" src="data/testrunner.js"></script>
+ <script type="text/javascript" src="unit/offset.js"></script>
+</head>
+
+<body id="body">
+ <h1 id="header">jQuery Offset Test Suite</h1>
+ <h2 id="banner"></h2>
+ <h2 id="userAgent"></h2>
+
+ <!-- Test HTML -->
+ <div id="nothiddendiv" style="height:1px;background:white;"></div>
+ <dl id="dl" style="display:none;">
+ <div id="main" style="display: none;">
+
+ </div>
+ </dl>
+
+ <ol id="tests"></ol>
+</body>
+</html>
diff --git a/dom/tests/mochitest/ajax/jquery/test/test.js b/dom/tests/mochitest/ajax/jquery/test/test.js
new file mode 100644
index 0000000000..e76b795a2c
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/test.js
@@ -0,0 +1,41 @@
+load( "build/js/writeFile.js", "build/js/parse.js" );
+
+function addParams(name, params) {
+ if(params.length > 0) {
+ name += "(";
+ for ( var i = 0; i < params.length; i++) {
+ name += params[i].type + ", ";
+ }
+ return name.substring(0, name.length - 2) + ")";
+ } else {
+ return name + "()";
+ }
+}
+function addTestWrapper(name, test) {
+ return 'test("' + name + '", function() {\n' + test + '\n});';
+}
+
+var dir = arguments[1];
+var jq = parse( read(arguments[0]) );
+
+var testFile = [];
+
+String.prototype.decode = function() {
+ return this.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
+};
+
+for ( var i = 0; i < jq.length; i++ ) {
+ if ( jq[i].tests.length > 0 ) {
+ var method = jq[i];
+ var name = addParams(method.name, method.params);
+ for(var j = 0; j < method.tests.length; j++) {
+ if(j > 0) {
+ name += "x";
+ }
+ testFile[testFile.length] = addTestWrapper(name, method.tests[j].decode()) + "\n";
+ }
+ }
+}
+
+var indexFile = readFile( "build/test/index.html" );
+writeFile( dir + "/index.html", indexFile.replace( /{TESTS}/g, testFile.join("\n") ) );
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/ajax.js b/dom/tests/mochitest/ajax/jquery/test/unit/ajax.js
new file mode 100644
index 0000000000..b60d39e72f
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/ajax.js
@@ -0,0 +1,837 @@
+module("ajax");
+
+// Safari 3 randomly crashes when running these tests,
+// but only in the full suite - you can run just the Ajax
+// tests and they'll pass
+//if ( !jQuery.browser.safari ) {
+
+if ( !isLocal ) {
+
+test("$.ajax() - success callbacks", function() {
+ expect( 8 );
+
+ $.ajaxSetup({ timeout: 0 });
+
+ stop();
+
+ setTimeout(function(){
+ $('#foo').ajaxStart(function(){
+ ok( true, "ajaxStart" );
+ }).ajaxStop(function(){
+ ok( true, "ajaxStop" );
+ start();
+ }).ajaxSend(function(){
+ ok( true, "ajaxSend" );
+ }).ajaxComplete(function(){
+ ok( true, "ajaxComplete" );
+ }).ajaxError(function(){
+ ok( false, "ajaxError" );
+ }).ajaxSuccess(function(){
+ ok( true, "ajaxSuccess" );
+ });
+
+ $.ajax({
+ url: url("data/name.html"),
+ beforeSend: function(){ ok(true, "beforeSend"); },
+ success: function(){ ok(true, "success"); },
+ error: function(){ ok(false, "error"); },
+ complete: function(){ ok(true, "complete"); }
+ });
+ }, 13);
+});
+
+/* mozilla: the ajaxSuccess part fails intermittently on MacOSX
+
+test("$.ajax() - error callbacks", function() {
+ expect( 7 );
+ stop();
+
+ $('#foo').ajaxStart(function(){
+ ok( true, "ajaxStart" );
+ }).ajaxStop(function(){
+ ok( true, "ajaxStop" );
+ start();
+ }).ajaxSend(function(){
+ ok( true, "ajaxSend" );
+ }).ajaxComplete(function(){
+ ok( true, "ajaxComplete" );
+ }).ajaxError(function(){
+ ok( true, "ajaxError" );
+ }).ajaxSuccess(function(){
+ ok( false, "ajaxSuccess" );
+ })
+ ;
+
+ $.ajaxSetup({ timeout: 500 });
+
+ $.ajax({
+ url: url("data/name.php?wait=5"),
+ beforeSend: function(){ ok(true, "beforeSend"); },
+ success: function(){ ok(false, "success"); },
+ error: function(){ ok(true, "error"); },
+ complete: function(){ ok(true, "complete"); }
+ });
+});
+
+*/
+
+test("$.ajax() - disabled globals", function() {
+ expect( 3 );
+ stop();
+
+ $('#foo').ajaxStart(function(){
+ ok( false, "ajaxStart" );
+ }).ajaxStop(function(){
+ ok( false, "ajaxStop" );
+ }).ajaxSend(function(){
+ ok( false, "ajaxSend" );
+ }).ajaxComplete(function(){
+ ok( false, "ajaxComplete" );
+ }).ajaxError(function(){
+ ok( false, "ajaxError" );
+ }).ajaxSuccess(function(){
+ ok( false, "ajaxSuccess" );
+ });
+
+ $.ajax({
+ global: false,
+ url: url("data/name.html"),
+ beforeSend: function(){ ok(true, "beforeSend"); },
+ success: function(){ ok(true, "success"); },
+ error: function(){ ok(false, "error"); },
+ complete: function(){
+ ok(true, "complete");
+ setTimeout(function(){ start(); }, 13);
+ }
+ });
+});
+
+test("$.ajax - xml: non-namespace elements inside namespaced elements", function() {
+ expect(3);
+ stop();
+ $.ajax({
+ url: url("data/with_fries.xml"),
+ dataType: "xml",
+ success: function(resp) {
+ equals( $("properties", resp).length, 1, 'properties in responseXML' );
+ equals( $("jsconf", resp).length, 1, 'jsconf in responseXML' );
+ equals( $("thing", resp).length, 2, 'things in responseXML' );
+ start();
+ }
+ });
+});
+
+test("$.ajax - beforeSend", function() {
+ expect(1);
+ stop();
+
+ var check = false;
+
+ $.ajaxSetup({ timeout: 0 });
+
+ $.ajax({
+ url: url("data/name.html"),
+ beforeSend: function(xml) {
+ check = true;
+ },
+ success: function(data) {
+ ok( check, "check beforeSend was executed" );
+ start();
+ }
+ });
+});
+
+test("$.ajax - beforeSend, cancel request (#2688)", function() {
+ expect(2);
+ var request = $.ajax({
+ url: url("data/name.html"),
+ beforeSend: function() {
+ ok( true, "beforeSend got called, canceling" );
+ return false;
+ },
+ success: function() {
+ ok( false, "request didn't get canceled" );
+ },
+ complete: function() {
+ ok( false, "request didn't get canceled" );
+ },
+ error: function() {
+ ok( false, "request didn't get canceled" );
+ }
+ });
+ ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
+});
+
+var foobar;
+
+test("$.ajax - dataType html", function() {
+ expect(5);
+ stop();
+
+ foobar = null;
+ testFoo = undefined;
+
+ var verifyEvaluation = function() {
+ equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
+ equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
+ start();
+ };
+
+ $.ajax({
+ dataType: "html",
+ url: url("data/test.html"),
+ success: function(data) {
+ $("#ap").html(data);
+ ok( data.match(/^html text/), 'Check content for datatype html' );
+ setTimeout(verifyEvaluation, 600);
+ }
+ });
+});
+
+test("serialize()", function() {
+ expect(6);
+
+ equals( $('#form').serialize(),
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
+ 'Check form serialization as query string');
+
+ equals( $('#form :input').serialize(),
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
+ 'Check input serialization as query string');
+
+ equals( $('#testForm').serialize(),
+ 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
+ 'Check form serialization as query string');
+
+ equals( $('#testForm :input').serialize(),
+ 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
+ 'Check input serialization as query string');
+
+ equals( $('#form, #testForm').serialize(),
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+ 'Multiple form serialization as query string');
+
+ equals( $('#form, #testForm :input').serialize(),
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+ 'Mixed form/input serialization as query string');
+});
+
+test("$.param()", function() {
+ expect(4);
+ var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
+ equals( $.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
+
+ params = {someName: [1, 2, 3], regularThing: "blah" };
+ equals( $.param(params), "someName=1&someName=2&someName=3&regularThing=blah", "with array" );
+
+ params = {"foo[]":["baz", 42, "All your base are belong to us"]};
+ equals( $.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
+
+ params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
+ equals( $.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
+});
+
+test("synchronous request", function() {
+ expect(1);
+ ok( /^{ "data"/.test( $.ajax({url: url("data/json_obj.js"), async: false}).responseText ), "check returned text" );
+});
+
+test("synchronous request with callbacks", function() {
+ expect(2);
+ var result;
+ $.ajax({url: url("data/json_obj.js"), async: false, success: function(data) { ok(true, "success callback executed"); result = data; } });
+ ok( /^{ "data"/.test( result ), "check returned text" );
+});
+
+test("pass-through request object", function() {
+ expect(8);
+ stop(true);
+
+ var target = "data/name.html";
+ var successCount = 0;
+ var errorCount = 0;
+ var errorEx = "";
+ var success = function() {
+ successCount++;
+ };
+ $("#foo").ajaxError(function (e, xml, s, ex) {
+ errorCount++;
+ errorEx += ": " + xml.status;
+ });
+ $("#foo").one('ajaxStop', function () {
+ equals(successCount, 5, "Check all ajax calls successful");
+ equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
+ $("#foo").unbind('ajaxError');
+ start();
+ });
+
+ ok( $.get(url(target), success), "get" );
+ ok( $.post(url(target), success), "post" );
+ ok( $.getScript(url("data/test.js"), success), "script" );
+ ok( $.getJSON(url("data/json_obj.js"), success), "json" );
+ ok( $.ajax({url: url(target), success: success}), "generic" );
+});
+
+/* mozilla: php not currently supported in mochitest (08/08/2008)
+test("ajax cache", function () {
+ expect(18);
+ stop();
+
+ var count = 0;
+
+ $("#firstp").bind("ajaxSuccess", function (e, xml, s) {
+ var re = /_=(.*?)(&|$)/g;
+ var oldOne = null;
+ for (var i = 0; i < 6; i++) {
+ var ret = re.exec(s.url);
+ if (!ret) {
+ break;
+ }
+ oldOne = ret[1];
+ }
+ equals(i, 1, "Test to make sure only one 'no-cache' parameter is there");
+ ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced");
+ if(++count == 6)
+ start();
+ });
+
+ ok( $.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
+ ok( $.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
+ ok( $.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
+ ok( $.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
+ ok( $.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
+ ok( $.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
+});
+*/
+
+test("global ajaxSettings", function() {
+ expect(2);
+
+ var tmp = jQuery.extend({}, jQuery.ajaxSettings);
+ var orig = { url: "data/with_fries.xml" };
+ var t;
+
+ $.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
+
+ t = jQuery.extend({}, orig);
+ t.data = {};
+ $.ajax(t);
+ ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
+
+ t = jQuery.extend({}, orig);
+ t.data = { zoo: 'a', ping: 'b' };
+ $.ajax(t);
+ ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" );
+
+ jQuery.ajaxSettings = tmp;
+});
+
+test("load(String)", function() {
+ expect(1);
+ stop(true); // check if load can be called with only url
+ $('#first').load("data/name.html", start);
+});
+
+test("load('url selector')", function() {
+ expect(1);
+ stop(true); // check if load can be called with only url
+ $('#first').load("data/test3.html div.user", function(){
+ equals( $(this).children("div").length, 2, "Verify that specific elements were injected" );
+ start();
+ });
+});
+
+test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
+ expect(1);
+ stop();
+ $.ajaxSetup({ dataType: "json" });
+ $("#first").ajaxComplete(function (e, xml, s) {
+ equals( s.dataType, "html", "Verify the load() dataType was html" );
+ $("#first").unbind("ajaxComplete");
+ $.ajaxSetup({ dataType: "" });
+ start();
+ });
+ $('#first').load("data/test3.html");
+});
+
+test("load(String, Function) - simple: inject text into DOM", function() {
+ expect(2);
+ stop();
+ $('#first').load(url("data/name.html"), function() {
+ ok( /^ERROR/.test($('#first').text()), 'Check if content was injected into the DOM' );
+ start();
+ });
+});
+
+test("load(String, Function) - check scripts", function() {
+ expect(7);
+ stop();
+ window.testFoo = undefined;
+ window.foobar = null;
+ var verifyEvaluation = function() {
+ equals( foobar, "bar", 'Check if script src was evaluated after load' );
+ equals( $('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
+ start();
+ };
+ $('#first').load(url('data/test.html'), function() {
+ ok( $('#first').html().match(/^html text/), 'Check content after loading html' );
+ equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
+ equals( testFoo, "foo", 'Check if script was evaluated after load' );
+ setTimeout(verifyEvaluation, 600);
+ });
+});
+
+test("load(String, Function) - check file with only a script tag", function() {
+ expect(3);
+ stop();
+ testFoo = undefined;
+ $('#first').load(url('data/test2.html'), function() {
+ equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
+ equals( testFoo, "foo", 'Check if script was evaluated after load' );
+ start();
+ });
+});
+
+test("$.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
+ expect(2);
+ stop();
+ $.get(url('data/dashboard.xml'), function(xml) {
+ var content = [];
+ $('tab', xml).each(function() {
+ content.push($(this).text());
+ });
+ equals( content[0], 'blabla', 'Check first tab');
+ equals( content[1], 'blublu', 'Check second tab');
+ start();
+ });
+});
+
+test("$.getScript(String, Function) - with callback", function() {
+ expect(2);
+ stop();
+ window.foobar = null;
+ $.getScript(url("data/test.js"), function() {
+ equals( foobar, "bar", 'Check if script was evaluated' );
+ setTimeout(start, 100);
+ });
+});
+
+test("$.getScript(String, Function) - no callback", function() {
+ expect(1);
+ stop(true);
+ $.getScript(url("data/test.js"), start);
+});
+
+/* mozilla: Tests using php scripts not currently supported (06/26/2008)
+
+test("$.ajax() - JSONP, Local", function() {
+ expect(7);
+
+ var count = 0;
+ function plus(){ if ( ++count == 7 ) start(); }
+
+ stop();
+
+ $.ajax({
+ url: "data/jsonp.php",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, no callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, no callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ url: "data/jsonp.php?callback=?",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, url callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, url callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ url: "data/jsonp.php",
+ dataType: "jsonp",
+ data: "callback=?",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, data callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, data callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ url: "data/jsonp.php",
+ dataType: "jsonp",
+ jsonp: "callback",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, data obj callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, data obj callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ type: "POST",
+ url: "data/jsonp.php",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (POST, no callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, data obj callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ type: "POST",
+ url: "data/jsonp.php",
+ data: "callback=?",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (POST, data callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (POST, data callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ type: "POST",
+ url: "data/jsonp.php",
+ jsonp: "callback",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (POST, data obj callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (POST, data obj callback)" );
+ plus();
+ }
+ });
+});
+
+test("$.ajax() - JSONP, Remote", function() {
+ expect(4);
+
+ var count = 0;
+ function plus(){ if ( ++count == 4 ) start(); }
+
+ var base = window.location.href.replace(/\?.*$/, "");
+
+ stop();
+
+ $.ajax({
+ url: base + "data/jsonp.php",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, no callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, no callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ url: base + "data/jsonp.php?callback=?",
+ dataType: "jsonp",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, url callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, url callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ url: base + "data/jsonp.php",
+ dataType: "jsonp",
+ data: "callback=?",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, data callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, data callback)" );
+ plus();
+ }
+ });
+
+ $.ajax({
+ url: base + "data/jsonp.php",
+ dataType: "jsonp",
+ jsonp: "callback",
+ success: function(data){
+ ok( data.data, "JSON results returned (GET, data obj callback)" );
+ plus();
+ },
+ error: function(data){
+ ok( false, "Ajax error JSON (GET, data obj callback)" );
+ plus();
+ }
+ });
+});
+
+test("$.ajax() - script, Remote", function() {
+ expect(2);
+
+ var base = window.location.href.replace(/\?.*$/, "");
+
+ stop();
+
+ window.foobar = null;
+ $.ajax({
+ url: base + "data/test.js",
+ dataType: "script",
+ success: function(data){
+ ok( foobar, "Script results returned (GET, no callback)" );
+ start();
+ }
+ });
+});
+
+test("$.ajax() - script, Remote with POST", function() {
+ expect(3);
+
+ var base = window.location.href.replace(/\?.*$/, "");
+
+ stop();
+
+ window.foobar = null;
+ $.ajax({
+ url: base + "data/test.js",
+ type: "POST",
+ dataType: "script",
+ success: function(data, status){
+ ok( foobar, "Script results returned (GET, no callback)" );
+ equals( status, "success", "Script results returned (GET, no callback)" );
+ start();
+ }
+ });
+});
+
+test("$.ajax() - script, Remote with scheme-less URL", function() {
+ expect(2);
+
+ var base = window.location.href.replace(/\?.*$/, "");
+ base = base.replace(/^.*?\/\//, "//");
+
+ stop();
+
+ window.foobar = null;
+ $.ajax({
+ url: base + "data/test.js",
+ dataType: "script",
+ success: function(data){
+ ok( foobar, "Script results returned (GET, no callback)" );
+ start();
+ }
+ });
+});
+
+test("$.getJSON(String, Hash, Function) - JSON array", function() {
+ expect(4);
+ stop();
+ $.getJSON(url("data/json.php"), {json: "array"}, function(json) {
+ equals( json[0].name, 'John', 'Check JSON: first, name' );
+ equals( json[0].age, 21, 'Check JSON: first, age' );
+ equals( json[1].name, 'Peter', 'Check JSON: second, name' );
+ equals( json[1].age, 25, 'Check JSON: second, age' );
+ start();
+ });
+});
+
+test("$.getJSON(String, Function) - JSON object", function() {
+ expect(2);
+ stop();
+ $.getJSON(url("data/json.php"), function(json) {
+ equals( json.data.lang, 'en', 'Check JSON: lang' );
+ equals( json.data.length, 25, 'Check JSON: length' );
+ start();
+ });
+});
+
+test("$.getJSON(String, Function) - JSON object with absolute url to local content", function() {
+ expect(2);
+
+ var base = window.location.href.replace(/\?.*$/, "");
+
+ stop();
+ $.getJSON(url(base + "data/json.php"), function(json) {
+ equals( json.data.lang, 'en', 'Check JSON: lang' );
+ equals( json.data.length, 25, 'Check JSON: length' );
+ start();
+ });
+});
+
+test("$.post(String, Hash, Function) - simple with xml", function() {
+ expect(4);
+ stop();
+ $.post(url("data/name.php"), {xml: "5-2"}, function(xml){
+ $('math', xml).each(function() {
+ equals( $('calculation', this).text(), '5-2', 'Check for XML' );
+ equals( $('result', this).text(), '3', 'Check for XML' );
+ });
+ });
+
+ $.post(url("data/name.php?xml=5-2"), {}, function(xml){
+ $('math', xml).each(function() {
+ equals( $('calculation', this).text(), '5-2', 'Check for XML' );
+ equals( $('result', this).text(), '3', 'Check for XML' );
+ });
+ start();
+ });
+});
+
+test("$.ajaxSetup({timeout: Number}) - with global timeout", function() {
+ stop();
+
+ var passed = 0;
+
+ $.ajaxSetup({timeout: 1000});
+
+ var pass = function() {
+ passed++;
+ if ( passed == 2 ) {
+ ok( true, 'Check local and global callbacks after timeout' );
+ $('#main').unbind("ajaxError");
+ start();
+ }
+ };
+
+ var fail = function(a,b,c) {
+ ok( false, 'Check for timeout failed ' + a + ' ' + b );
+ start();
+ };
+
+ $('#main').ajaxError(pass);
+
+ $.ajax({
+ type: "GET",
+ url: url("data/name.php?wait=5"),
+ error: pass,
+ success: fail
+ });
+
+ // reset timeout
+ $.ajaxSetup({timeout: 0});
+});
+
+test("$.ajaxSetup({timeout: Number}) with localtimeout", function() {
+ stop();
+ $.ajaxSetup({timeout: 50});
+
+ $.ajax({
+ type: "GET",
+ timeout: 5000,
+ url: url("data/name.php?wait=1"),
+ error: function() {
+ ok( false, 'Check for local timeout failed' );
+ start();
+ },
+ success: function() {
+ ok( true, 'Check for local timeout' );
+ start();
+ }
+ });
+
+ // reset timeout
+ $.ajaxSetup({timeout: 0});
+});
+
+test("$.ajax - simple get", function() {
+ expect(1);
+ stop();
+ $.ajax({
+ type: "GET",
+ url: url("data/name.php?name=foo"),
+ success: function(msg){
+ equals( msg, 'bar', 'Check for GET' );
+ start();
+ }
+ });
+});
+
+test("$.ajax - simple post", function() {
+ expect(1);
+ stop();
+ $.ajax({
+ type: "POST",
+ url: url("data/name.php"),
+ data: "name=peter",
+ success: function(msg){
+ equals( msg, 'pan', 'Check for POST' );
+ start();
+ }
+ });
+});
+
+test("ajaxSetup()", function() {
+ expect(1);
+ stop();
+ $.ajaxSetup({
+ url: url("data/name.php?name=foo"),
+ success: function(msg){
+ equals( msg, 'bar', 'Check for GET' );
+ start();
+ }
+ });
+ $.ajax();
+});
+
+test("custom timeout does not set error message when timeout occurs, see #970", function() {
+ stop();
+ $.ajax({
+ url: "data/name.php?wait=10",
+ timeout: 500,
+ error: function(request, status) {
+ ok( status != null, "status shouldn't be null in error handler" );
+ equals( "timeout", status );
+ start();
+ }
+ });
+});
+
+test("data option: evaluate function values (#2806)", function() {
+ stop();
+ $.ajax({
+ url: "data/echoQuery.php",
+ data: {
+ key: function() {
+ return "value";
+ }
+ },
+ success: function(result) {
+ equals( result, "key=value" );
+ start();
+ }
+ })
+});
+*/
+}
+
+//}
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/core.js b/dom/tests/mochitest/ajax/jquery/test/unit/core.js
new file mode 100644
index 0000000000..74a03192c0
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/core.js
@@ -0,0 +1,1700 @@
+module("core");
+
+test("Basic requirements", function() {
+ expect(7);
+ ok( Array.prototype.push, "Array.push()" );
+ ok( Function.prototype.apply, "Function.apply()" );
+ ok( document.getElementById, "getElementById" );
+ ok( document.getElementsByTagName, "getElementsByTagName" );
+ ok( RegExp, "RegExp" );
+ ok( jQuery, "jQuery" );
+ ok( $, "$()" );
+});
+
+test("$()", function() {
+ expect(8);
+
+ var main = $("#main");
+ isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
+
+/*
+ // disabled since this test was doing nothing. i tried to fix it but i'm not sure
+ // what the expected behavior should even be. FF returns "\n" for the text node
+ // make sure this is handled
+ var crlfContainer = $('<p>\r\n</p>');
+ var x = crlfContainer.contents().get(0).nodeValue;
+ equals( x, what???, "Check for \\r and \\n in jQuery()" );
+*/
+
+ /* // Disabled until we add this functionality in
+ var pass = true;
+ try {
+ $("<div>Testing</div>").appendTo(document.getElementById("iframe").contentDocument.body);
+ } catch(e){
+ pass = false;
+ }
+ ok( pass, "$('&lt;tag&gt;') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
+
+ var code = $("<code/>");
+ equals( code.length, 1, "Correct number of elements generated for code" );
+ var img = $("<img/>");
+ equals( img.length, 1, "Correct number of elements generated for img" );
+ var div = $("<div/><hr/><code/><b/>");
+ equals( div.length, 4, "Correct number of elements generated for div hr code b" );
+
+ // can actually yield more than one, when iframes are included, the window is an array as well
+ equals( $(window).length, 1, "Correct number of elements generated for window" );
+
+ equals( $(document).length, 1, "Correct number of elements generated for document" );
+
+ equals( $([1,2,3]).get(1), 2, "Test passing an array to the factory" );
+
+ equals( $(document.body).get(0), $('body').get(0), "Test passing an html node to the factory" );
+});
+
+test("browser", function() {
+ expect(13);
+ var browsers = {
+ //Internet Explorer
+ "Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)": "6.0",
+ "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)": "7.0",
+ /** Failing #1876
+ * "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30)": "7.0",
+ */
+ //Browsers with Gecko engine
+ //Mozilla
+ "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915" : "1.7.12",
+ //Firefox
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3": "1.8.1.3",
+ //Netscape
+ "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20070321 Netscape/8.1.3" : "1.7.5",
+ //Flock
+ "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070321 Firefox/1.5.0.11 Flock/0.7.12" : "1.8.0.11",
+ //Opera browser
+ "Opera/9.20 (X11; Linux x86_64; U; en)": "9.20",
+ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.20" : "9.20",
+ "Mozilla/5.0 (Windows NT 5.1; U; pl; rv:1.8.0) Gecko/20060728 Firefox/1.5.0 Opera 9.20": "9.20",
+ //WebKit engine
+ "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3": "418.9",
+ "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3" : "418.8",
+ "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/312.8 (KHTML, like Gecko) Safari/312.5": "312.8",
+ //Other user agent string
+ "Other browser's user agent 1.0":null
+ };
+ for (var i in browsers) {
+ var v = i.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ); // RegEx from Core jQuery.browser.version check
+ version = v ? v[1] : null;
+ equals( version, browsers[i], "Checking UA string" );
+ }
+});
+
+test("noConflict", function() {
+ expect(6);
+
+ var old = jQuery;
+ var newjQuery = jQuery.noConflict();
+
+ equals( newjQuery, old, "noConflict returned the jQuery object" );
+ equals( jQuery, old, "Make sure jQuery wasn't touched." );
+ equals( $, "$", "Make sure $ was reverted." );
+
+ jQuery = $ = old;
+
+ newjQuery = jQuery.noConflict(true);
+
+ equals( newjQuery, old, "noConflict returned the jQuery object" );
+ equals( jQuery, "jQuery", "Make sure jQuery was reverted." );
+ equals( $, "$", "Make sure $ was reverted." );
+
+ jQuery = $ = old;
+});
+
+test("isFunction", function() {
+ expect(21);
+
+ // Make sure that false values return false
+ ok( !jQuery.isFunction(), "No Value" );
+ ok( !jQuery.isFunction( null ), "null Value" );
+ ok( !jQuery.isFunction( undefined ), "undefined Value" );
+ ok( !jQuery.isFunction( "" ), "Empty String Value" );
+ ok( !jQuery.isFunction( 0 ), "0 Value" );
+
+ // Check built-ins
+ // Safari uses "(Internal Function)"
+ ok( jQuery.isFunction(String), "String Function("+String+")" );
+ ok( jQuery.isFunction(Array), "Array Function("+Array+")" );
+ ok( jQuery.isFunction(Object), "Object Function("+Object+")" );
+ ok( jQuery.isFunction(Function), "Function Function("+Function+")" );
+
+ // When stringified, this could be misinterpreted
+ var mystr = "function";
+ ok( !jQuery.isFunction(mystr), "Function String" );
+
+ // When stringified, this could be misinterpreted
+ var myarr = [ "function" ];
+ ok( !jQuery.isFunction(myarr), "Function Array" );
+
+ // When stringified, this could be misinterpreted
+ var myfunction = { "function": "test" };
+ ok( !jQuery.isFunction(myfunction), "Function Object" );
+
+ // Make sure normal functions still work
+ var fn = function(){};
+ ok( jQuery.isFunction(fn), "Normal Function" );
+
+ var obj = document.createElement("object");
+
+ // Firefox says this is a function
+ ok( !jQuery.isFunction(obj), "Object Element" );
+
+ // IE says this is an object
+ ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );
+
+ var nodes = document.body.childNodes;
+
+ // Safari says this is a function
+ ok( !jQuery.isFunction(nodes), "childNodes Property" );
+
+ var first = document.body.firstChild;
+
+ // Normal elements are reported ok everywhere
+ ok( !jQuery.isFunction(first), "A normal DOM Element" );
+
+ var input = document.createElement("input");
+ input.type = "text";
+ document.body.appendChild( input );
+
+ // IE says this is an object
+ ok( jQuery.isFunction(input.focus), "A default function property" );
+
+ document.body.removeChild( input );
+
+ var a = document.createElement("a");
+ a.href = "some-function";
+ document.body.appendChild( a );
+
+ // This serializes with the word 'function' in it
+ ok( !jQuery.isFunction(a), "Anchor Element" );
+
+ document.body.removeChild( a );
+
+ // Recursive function calls have lengths and array-like properties
+ function callme(callback){
+ function fn(response){
+ callback(response);
+ }
+
+ ok( jQuery.isFunction(fn), "Recursive Function Call" );
+
+ fn({ some: "data" });
+ };
+
+ callme(function(){
+ callme(function(){});
+ });
+});
+
+var foo = false;
+
+test("$('html')", function() {
+ expect(6);
+
+ reset();
+ foo = false;
+ var s = $("<script>var foo='test';</script>")[0];
+ ok( s, "Creating a script" );
+ ok( !foo, "Make sure the script wasn't executed prematurely" );
+ $("body").append(s);
+ ok( foo, "Executing a scripts contents in the right context" );
+
+ reset();
+ ok( $("<link rel='stylesheet'/>")[0], "Creating a link" );
+
+ reset();
+
+ var j = $("<span>hi</span> there <!-- mon ami -->");
+ ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" );
+
+ ok( !$("<option>test</option>")[0].selected, "Make sure that options are auto-selected #2050" );
+});
+
+test("$('html', context)", function() {
+ expect(1);
+
+ var $div = $("<div/>");
+ var $span = $("<span/>", $div);
+ equals($span.length, 1, "Verify a span created with a div context works, #1763");
+});
+
+if ( !isLocal ) {
+test("$(selector, xml).text(str) - Loaded via XML document", function() {
+ expect(2);
+ stop();
+ $.get('data/dashboard.xml', function(xml) {
+ // tests for #1419 where IE was a problem
+ equals( $("tab:first", xml).text(), "blabla", "Verify initial text correct" );
+ $("tab:first", xml).text("newtext");
+ equals( $("tab:first", xml).text(), "newtext", "Verify new text correct" );
+ start();
+ });
+});
+}
+
+test("length", function() {
+ expect(1);
+ equals( $("p").length, 6, "Get Number of Elements Found" );
+});
+
+test("size()", function() {
+ expect(1);
+ equals( $("p").size(), 6, "Get Number of Elements Found" );
+});
+
+test("get()", function() {
+ expect(1);
+ isSet( $("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
+});
+
+test("get(Number)", function() {
+ expect(1);
+ equals( $("p").get(0), document.getElementById("firstp"), "Get A Single Element" );
+});
+
+test("add(String|Element|Array|undefined)", function() {
+ expect(12);
+ isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
+ isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
+ ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
+
+ // For the time being, we're discontinuing support for $(form.elements) since it's ambiguous in IE
+ // use $([]).add(form.elements) instead.
+ //equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
+
+ var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));
+ equals( x[0].id, "x1", "Check on-the-fly element1" );
+ equals( x[1].id, "x2", "Check on-the-fly element2" );
+
+ var x = $([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");
+ equals( x[0].id, "x1", "Check on-the-fly element1" );
+ equals( x[1].id, "x2", "Check on-the-fly element2" );
+
+ var notDefined;
+ equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing" );
+
+ // Added after #2811
+ equals( $([]).add([window,document,document.body,document]).length, 3, "Pass an array" );
+ equals( $(document).add(document).length, 1, "Check duplicated elements" );
+ equals( $(window).add(window).length, 1, "Check duplicated elements using the window" );
+ ok( $([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );
+});
+
+test("each(Function)", function() {
+ expect(1);
+ var div = $("div");
+ div.each(function(){this.foo = 'zoo';});
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).foo != "zoo" ) pass = false;
+ }
+ ok( pass, "Execute a function, Relative" );
+});
+
+test("index(Object)", function() {
+ expect(10);
+
+ var elements = $([window, document]),
+ inputElements = $('#radio1,#radio2,#check1,#check2');
+
+ equals( elements.index(window), 0, "Check for index of elements" );
+ equals( elements.index(document), 1, "Check for index of elements" );
+ equals( inputElements.index(document.getElementById('radio1')), 0, "Check for index of elements" );
+ equals( inputElements.index(document.getElementById('radio2')), 1, "Check for index of elements" );
+ equals( inputElements.index(document.getElementById('check1')), 2, "Check for index of elements" );
+ equals( inputElements.index(document.getElementById('check2')), 3, "Check for index of elements" );
+ equals( inputElements.index(window), -1, "Check for not found index" );
+ equals( inputElements.index(document), -1, "Check for not found index" );
+
+ // enabled since [5500]
+ equals( elements.index( elements ), 0, "Pass in a jQuery object" );
+ equals( elements.index( elements.eq(1) ), 1, "Pass in a jQuery object" );
+});
+
+test("attr(String)", function() {
+ expect(29);
+ equals( $('#text1').attr('value'), "Test", 'Check for value attribute' );
+ equals( $('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' );
+ equals( $('#text1').attr('type'), "text", 'Check for type attribute' );
+ equals( $('#radio1').attr('type'), "radio", 'Check for type attribute' );
+ equals( $('#check1').attr('type'), "checkbox", 'Check for type attribute' );
+ equals( $('#simon1').attr('rel'), "bookmark", 'Check for rel attribute' );
+ equals( $('#google').attr('title'), "Google!", 'Check for title attribute' );
+ equals( $('#mark').attr('hreflang'), "en", 'Check for hreflang attribute' );
+ equals( $('#en').attr('lang'), "en", 'Check for lang attribute' );
+ equals( $('#simon').attr('class'), "blog link", 'Check for class attribute' );
+ equals( $('#name').attr('name'), "name", 'Check for name attribute' );
+ equals( $('#text1').attr('name'), "action", 'Check for name attribute' );
+ ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
+ equals( $('#text1').attr('minlength'), '20', 'Check for minlength attribute' );
+ equals( $('#text1').attr('minLength'), '20', 'Check for minLength attribute' );
+ equals( $('#area1').attr('minLength'), '20', 'Check for minLength attribute' );
+ equals( $('#text1').attr('maxlength'), '30', 'Check for maxlength attribute' );
+ equals( $('#text1').attr('maxLength'), '30', 'Check for maxLength attribute' );
+ equals( $('#area1').attr('maxLength'), '30', 'Check for maxLength attribute' );
+ equals( $('#select2').attr('selectedIndex'), 3, 'Check for selectedIndex attribute' );
+ equals( $('#foo').attr('nodeName'), 'DIV', 'Check for nodeName attribute' );
+ equals( $('#foo').attr('tagName'), 'DIV', 'Check for tagName attribute' );
+
+ $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path
+ equals( $('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
+
+
+ // Related to [5574] and [5683]
+ var body = document.body, $body = $(body);
+
+ ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' );
+ ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' );
+
+ body.setAttribute('foo', 'baz');
+ equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' );
+
+ body.foo = 'bar';
+ equals( $body.attr('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' );
+
+ $body.attr('foo','cool');
+ equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' );
+
+ body.foo = undefined;
+ ok( $body.attr('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' );
+
+ body.removeAttribute('foo'); // Cleanup
+});
+
+if ( !isLocal ) {
+ test("attr(String) in XML Files", function() {
+ expect(2);
+ stop();
+ $.get("data/dashboard.xml", function(xml) {
+ equals( $("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );
+ equals( $("location", xml).attr("for"), "bar", "Check for attribute in XML document" );
+ start();
+ });
+ });
+}
+
+test("attr(String, Function)", function() {
+ expect(2);
+ equals( $('#text1').attr('value', function() { return this.id })[0].value, "text1", "Set value from id" );
+ equals( $('#text1').attr('title', function(i) { return i }).attr('title'), "0", "Set value with an index");
+});
+
+test("attr(Hash)", function() {
+ expect(1);
+ var pass = true;
+ $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
+ if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
+ });
+ ok( pass, "Set Multiple Attributes" );
+});
+
+test("attr(String, Object)", function() {
+ expect(19);
+ var div = $("div").attr("foo", "bar");
+ fail = false;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).getAttribute('foo') != "bar" ){
+ fail = i;
+ break;
+ }
+ }
+ equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );
+
+ ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
+
+ $("#name").attr('name', 'something');
+ equals( $("#name").attr('name'), 'something', 'Set name attribute' );
+ $("#check2").attr('checked', true);
+ equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
+ $("#check2").attr('checked', false);
+ equals( document.getElementById('check2').checked, false, 'Set checked attribute' );
+ $("#text1").attr('readonly', true);
+ equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' );
+ $("#text1").attr('readonly', false);
+ equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' );
+ $("#name").attr('maxlength', '5');
+ equals( document.getElementById('name').maxLength, '5', 'Set maxlength attribute' );
+ $("#name").attr('maxLength', '10');
+ equals( document.getElementById('name').maxLength, '10', 'Set maxlength attribute' );
+ $("#name").attr('minlength', '5');
+ equals( document.getElementById('name').minLength, '5', 'Set minlength attribute' );
+ $("#name").attr('minLength', '10');
+ equals( document.getElementById('name').minLength, '10', 'Set minlength attribute' );
+
+ // for #1070
+ $("#name").attr('someAttr', '0');
+ equals( $("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
+ $("#name").attr('someAttr', 0);
+ equals( $("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );
+ $("#name").attr('someAttr', 1);
+ equals( $("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+
+ j.attr("name", "attrvalue");
+ equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );
+ j.removeAttr("name");
+
+ reset();
+
+ var type = $("#check2").attr('type');
+ var thrown = false;
+ try {
+ $("#check2").attr('type','hidden');
+ } catch(e) {
+ thrown = true;
+ }
+ ok( thrown, "Exception thrown when trying to change type property" );
+ equals( type, $("#check2").attr('type'), "Verify that you can't change the type of an input element" );
+
+ var check = document.createElement("input");
+ var thrown = true;
+ try {
+ $(check).attr('type','checkbox');
+ } catch(e) {
+ thrown = false;
+ }
+ ok( thrown, "Exception thrown when trying to change type property" );
+ equals( "checkbox", $(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
+});
+
+if ( !isLocal ) {
+ test("attr(String, Object) - Loaded via XML document", function() {
+ expect(2);
+ stop();
+ $.get('data/dashboard.xml', function(xml) {
+ var titles = [];
+ $('tab', xml).each(function() {
+ titles.push($(this).attr('title'));
+ });
+ equals( titles[0], 'Location', 'attr() in XML context: Check first title' );
+ equals( titles[1], 'Users', 'attr() in XML context: Check second title' );
+ start();
+ });
+ });
+}
+
+test("css(String|Hash)", function() {
+ expect(19);
+
+ equals( $('#main').css("display"), 'none', 'Check for css property "display"');
+
+ ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
+ $('#foo').css({display: 'none'});
+ ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
+ $('#foo').css({display: 'block'});
+ ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+
+ $('#floatTest').css({styleFloat: 'right'});
+ equals( $('#floatTest').css('styleFloat'), 'right', 'Modified CSS float using "styleFloat": Assert float is right');
+ $('#floatTest').css({cssFloat: 'left'});
+ equals( $('#floatTest').css('cssFloat'), 'left', 'Modified CSS float using "cssFloat": Assert float is left');
+ $('#floatTest').css({'float': 'right'});
+ equals( $('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
+ $('#floatTest').css({'font-size': '30px'});
+ equals( $('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');
+
+ $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
+ $('#foo').css({opacity: n});
+ equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
+ $('#foo').css({opacity: parseFloat(n)});
+ equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
+ });
+ $('#foo').css({opacity: ''});
+ equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
+});
+
+test("css(String, Object)", function() {
+ expect(21);
+ ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
+ $('#foo').css('display', 'none');
+ ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
+ $('#foo').css('display', 'block');
+ ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+
+ $('#floatTest').css('styleFloat', 'left');
+ equals( $('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left');
+ $('#floatTest').css('cssFloat', 'right');
+ equals( $('#floatTest').css('cssFloat'), 'right', 'Modified CSS float using "cssFloat": Assert float is right');
+ $('#floatTest').css('float', 'left');
+ equals( $('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');
+ $('#floatTest').css('font-size', '20px');
+ equals( $('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');
+
+ $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
+ $('#foo').css('opacity', n);
+ equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
+ $('#foo').css('opacity', parseFloat(n));
+ equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
+ });
+ $('#foo').css('opacity', '');
+ equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
+ // for #1438, IE throws JS error when filter exists but doesn't have opacity in it
+ if (jQuery.browser.msie) {
+ $('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
+ }
+ equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.css("padding-left", "1px");
+ equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );
+
+ // opera sometimes doesn't update 'display' correctly, see #2037
+ $("#t2037")[0].innerHTML = $("#t2037")[0].innerHTML
+ equals( $("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
+});
+
+test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {
+ expect(4);
+
+ var $checkedtest = $("#checkedtest");
+ // IE6 was clearing "checked" in jQuery.css(elem, "height");
+ jQuery.css($checkedtest[0], "height");
+ ok( !! $(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
+ ok( ! $(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
+ ok( !! $(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
+ ok( ! $(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
+});
+
+test("width()", function() {
+ expect(9);
+
+ var $div = $("#nothiddendiv");
+ $div.width(30);
+ equals($div.width(), 30, "Test set to 30 correctly");
+ $div.width(-1); // handle negative numbers by ignoring #1599
+ equals($div.width(), 30, "Test negative width ignored");
+ $div.css("padding", "20px");
+ equals($div.width(), 30, "Test padding specified with pixels");
+ $div.css("border", "2px solid #fff");
+ equals($div.width(), 30, "Test border specified with pixels");
+ $div.css("padding", "2em");
+ equals($div.width(), 30, "Test padding specified with ems");
+ $div.css("border", "1em solid #fff");
+ equals($div.width(), 30, "Test border specified with ems");
+ $div.css("padding", "2%");
+ equals($div.width(), 30, "Test padding specified with percent");
+ $div.hide();
+ equals($div.width(), 30, "Test hidden div");
+
+ $div.css({ display: "", border: "", padding: "" });
+
+ $("#nothiddendivchild").css({ padding: "3px", border: "2px solid #fff" });
+ equals($("#nothiddendivchild").width(), 20, "Test child width with border and padding");
+ $("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
+});
+
+test("height()", function() {
+ expect(8);
+
+ var $div = $("#nothiddendiv");
+ $div.height(30);
+ equals($div.height(), 30, "Test set to 30 correctly");
+ $div.height(-1); // handle negative numbers by ignoring #1599
+ equals($div.height(), 30, "Test negative height ignored");
+ $div.css("padding", "20px");
+ equals($div.height(), 30, "Test padding specified with pixels");
+ $div.css("border", "2px solid #fff");
+ equals($div.height(), 30, "Test border specified with pixels");
+ $div.css("padding", "2em");
+ equals($div.height(), 30, "Test padding specified with ems");
+ $div.css("border", "1em solid #fff");
+ equals($div.height(), 30, "Test border specified with ems");
+ $div.css("padding", "2%");
+ equals($div.height(), 30, "Test padding specified with percent");
+ $div.hide();
+ equals($div.height(), 30, "Test hidden div");
+
+ $div.css({ display: "", border: "", padding: "", height: "1px" });
+});
+
+test("text()", function() {
+ expect(1);
+ var expected = "This link has class=\"blog\": Simon Willison's Weblog";
+ equals( $('#sap').text(), expected, 'Check for merged text of more then one element.' );
+});
+
+test("wrap(String|Element)", function() {
+ expect(8);
+ var defaultText = 'Try them out:'
+ var result = $('#first').wrap('<div class="red"><span></span></div>').text();
+ equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
+ ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+
+ reset();
+ var defaultText = 'Try them out:'
+ var result = $('#first').wrap(document.getElementById('empty')).parent();
+ ok( result.is('ol'), 'Check for element wrapping' );
+ equals( result.text(), defaultText, 'Check for element wrapping' );
+
+ reset();
+ $('#check1').click(function() {
+ var checkbox = this;
+ ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
+ $(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
+ ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
+ }).click();
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.wrap("<i></i>");
+ equals( $("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
+ equals( $("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );
+});
+
+test("wrapAll(String|Element)", function() {
+ expect(8);
+ var prev = $("#first")[0].previousSibling;
+ var p = $("#first")[0].parentNode;
+ var result = $('#first,#firstp').wrapAll('<div class="red"><div id="tmp"></div></div>');
+ equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
+ ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+ ok( $('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+ equals( $("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
+ equals( $("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
+
+ reset();
+ var prev = $("#first")[0].previousSibling;
+ var p = $("#first")[0].parentNode;
+ var result = $('#first,#firstp').wrapAll(document.getElementById('empty'));
+ equals( $("#first").parent()[0], $("#firstp").parent()[0], "Same Parent" );
+ equals( $("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
+ equals( $("#first").parent()[0].parentNode, p, "Correct Parent" );
+});
+
+test("wrapInner(String|Element)", function() {
+ expect(6);
+ var num = $("#first").children().length;
+ var result = $('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');
+ equals( $("#first").children().length, 1, "Only one child" );
+ ok( $("#first").children().is(".red"), "Verify Right Element" );
+ equals( $("#first").children().children().children().length, num, "Verify Elements Intact" );
+
+ reset();
+ var num = $("#first").children().length;
+ var result = $('#first').wrapInner(document.getElementById('empty'));
+ equals( $("#first").children().length, 1, "Only one child" );
+ ok( $("#first").children().is("#empty"), "Verify Right Element" );
+ equals( $("#first").children().children().length, num, "Verify Elements Intact" );
+});
+
+test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(21);
+ var defaultText = 'Try them out:'
+ var result = $('#first').append('<b>buga</b>');
+ equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
+ equals( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
+
+ reset();
+ var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
+ $('#sap').append(document.getElementById('first'));
+ equals( expected, $('#sap').text(), "Check for appending of element" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
+ equals( expected, $('#sap').text(), "Check for appending of array of elements" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $('#sap').append($("#first, #yahoo"));
+ equals( expected, $('#sap').text(), "Check for appending of jQuery object" );
+
+ reset();
+ $("#sap").append( 5 );
+ ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
+
+ reset();
+ $("#sap").append( " text with spaces " );
+ ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
+
+ reset();
+ ok( $("#sap").append([]), "Check for appending an empty array." );
+ ok( $("#sap").append(""), "Check for appending an empty string." );
+ ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
+
+ reset();
+ $("#sap").append(document.getElementById('form'));
+ equals( $("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910
+
+ reset();
+ var pass = true;
+ try {
+ $( $("#iframe")[0].contentWindow.document.body ).append("<div>test</div>");
+ } catch(e) {
+ pass = false;
+ }
+
+ ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
+
+ reset();
+ $('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');
+ t( 'Append legend', '#legend', ['legend'] );
+
+ reset();
+ $('#select1').append('<OPTION>Test</OPTION>');
+ equals( $('#select1 option:last').text(), "Test", "Appending &lt;OPTION&gt; (all caps)" );
+
+ $('#table').append('<colgroup></colgroup>');
+ ok( $('#table colgroup').length, "Append colgroup" );
+
+ $('#table colgroup').append('<col/>');
+ ok( $('#table colgroup col').length, "Append col" );
+
+ reset();
+ $('#table').append('<caption></caption>');
+ ok( $('#table caption').length, "Append caption" );
+
+ reset();
+ $('form:last')
+ .append('<select id="appendSelect1"></select>')
+ .append('<select id="appendSelect2"><option>Test</option></select>');
+
+ t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ var d = $("<div/>").appendTo("#nonnodes").append(j);
+ equals( $("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
+ ok( d.contents().length >= 2, "Check node,textnode,comment append works" );
+ d.contents().appendTo("#nonnodes");
+ d.remove();
+ ok( $("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
+});
+
+test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(6);
+ var defaultText = 'Try them out:'
+ $('<b>buga</b>').appendTo('#first');
+ equals( $("#first").text(), defaultText + 'buga', 'Check if text appending works' );
+ equals( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
+
+ reset();
+ var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
+ $(document.getElementById('first')).appendTo('#sap');
+ equals( expected, $('#sap').text(), "Check for appending of element" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
+ equals( expected, $('#sap').text(), "Check for appending of array of elements" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $("#first, #yahoo").appendTo('#sap');
+ equals( expected, $('#sap').text(), "Check for appending of jQuery object" );
+
+ reset();
+ $('#select1').appendTo('#foo');
+ t( 'Append select', '#foo select', ['select1'] );
+});
+
+test("prepend(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(5);
+ var defaultText = 'Try them out:'
+ var result = $('#first').prepend('<b>buga</b>');
+ equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
+ equals( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
+
+ reset();
+ var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend(document.getElementById('first'));
+ equals( expected, $('#sap').text(), "Check for prepending of element" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
+ equals( expected, $('#sap').text(), "Check for prepending of array of elements" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend($("#first, #yahoo"));
+ equals( expected, $('#sap').text(), "Check for prepending of jQuery object" );
+});
+
+test("prependTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(6);
+ var defaultText = 'Try them out:'
+ $('<b>buga</b>').prependTo('#first');
+ equals( $('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );
+ equals( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
+
+ reset();
+ var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
+ $(document.getElementById('first')).prependTo('#sap');
+ equals( expected, $('#sap').text(), "Check for prepending of element" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');
+ equals( expected, $('#sap').text(), "Check for prepending of array of elements" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $("#yahoo, #first").prependTo('#sap');
+ equals( expected, $('#sap').text(), "Check for prepending of jQuery object" );
+
+ reset();
+ $('<select id="prependSelect1"></select>').prependTo('form:last');
+ $('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
+
+ t( "Prepend Select", "#prependSelect1, #prependSelect2", ["prependSelect1", "prependSelect2"] );
+});
+
+test("before(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: bugaYahoo';
+ $('#yahoo').before('<b>buga</b>');
+ equals( expected, $('#en').text(), 'Insert String before' );
+
+ reset();
+ expected = "This is a normal link: Try them out:Yahoo";
+ $('#yahoo').before(document.getElementById('first'));
+ equals( expected, $('#en').text(), "Insert element before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
+ equals( expected, $('#en').text(), "Insert array of elements before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $('#yahoo').before($("#first, #mark"));
+ equals( expected, $('#en').text(), "Insert jQuery before" );
+});
+
+test("insertBefore(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: bugaYahoo';
+ $('<b>buga</b>').insertBefore('#yahoo');
+ equals( expected, $('#en').text(), 'Insert String before' );
+
+ reset();
+ expected = "This is a normal link: Try them out:Yahoo";
+ $(document.getElementById('first')).insertBefore('#yahoo');
+ equals( expected, $('#en').text(), "Insert element before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
+ equals( expected, $('#en').text(), "Insert array of elements before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $("#first, #mark").insertBefore('#yahoo');
+ equals( expected, $('#en').text(), "Insert jQuery before" );
+});
+
+test("after(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: Yahoobuga';
+ $('#yahoo').after('<b>buga</b>');
+ equals( expected, $('#en').text(), 'Insert String after' );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:";
+ $('#yahoo').after(document.getElementById('first'));
+ equals( expected, $('#en').text(), "Insert element after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
+ equals( expected, $('#en').text(), "Insert array of elements after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $('#yahoo').after($("#first, #mark"));
+ equals( expected, $('#en').text(), "Insert jQuery after" );
+});
+
+test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: Yahoobuga';
+ $('<b>buga</b>').insertAfter('#yahoo');
+ equals( expected, $('#en').text(), 'Insert String after' );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:";
+ $(document.getElementById('first')).insertAfter('#yahoo');
+ equals( expected, $('#en').text(), "Insert element after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');
+ equals( expected, $('#en').text(), "Insert array of elements after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $("#mark, #first").insertAfter('#yahoo');
+ equals( expected, $('#en').text(), "Insert jQuery after" );
+});
+
+test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(10);
+ $('#yahoo').replaceWith('<b id="replace">buga</b>');
+ ok( $("#replace")[0], 'Replace element with string' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
+
+ reset();
+ $('#yahoo').replaceWith(document.getElementById('first'));
+ ok( $("#first")[0], 'Replace element with element' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );
+
+ reset();
+ $('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);
+ ok( $("#first")[0], 'Replace element with array of elements' );
+ ok( $("#mark")[0], 'Replace element with array of elements' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
+
+ reset();
+ $('#yahoo').replaceWith($("#first, #mark"));
+ ok( $("#first")[0], 'Replace element with set of elements' );
+ ok( $("#mark")[0], 'Replace element with set of elements' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
+});
+
+test("replaceAll(String|Element|Array&lt;Element&gt;|jQuery)", function() {
+ expect(10);
+ $('<b id="replace">buga</b>').replaceAll("#yahoo");
+ ok( $("#replace")[0], 'Replace element with string' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
+
+ reset();
+ $(document.getElementById('first')).replaceAll("#yahoo");
+ ok( $("#first")[0], 'Replace element with element' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );
+
+ reset();
+ $([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
+ ok( $("#first")[0], 'Replace element with array of elements' );
+ ok( $("#mark")[0], 'Replace element with array of elements' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
+
+ reset();
+ $("#first, #mark").replaceAll("#yahoo");
+ ok( $("#first")[0], 'Replace element with set of elements' );
+ ok( $("#mark")[0], 'Replace element with set of elements' );
+ ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
+});
+
+test("end()", function() {
+ expect(3);
+ equals( 'Yahoo', $('#yahoo').parent().end().text(), 'Check for end' );
+ ok( $('#yahoo').end(), 'Check for end with nothing to end' );
+
+ var x = $('#yahoo');
+ x.parent();
+ equals( 'Yahoo', $('#yahoo').text(), 'Check for non-destructive behaviour' );
+});
+
+test("find(String)", function() {
+ expect(2);
+ equals( 'Yahoo', $('#foo').find('.blogTest').text(), 'Check for find' );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ equals( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
+});
+
+test("clone()", function() {
+ expect(20);
+ equals( 'This is a normal link: Yahoo', $('#en').text(), 'Assert text for #en' );
+ var clone = $('#yahoo').clone();
+ equals( 'Try them out:Yahoo', $('#first').append(clone).text(), 'Check for clone' );
+ equals( 'This is a normal link: Yahoo', $('#en').text(), 'Reassert text for #en' );
+
+ var cloneTags = [
+ "<table/>", "<tr/>", "<td/>", "<div/>",
+ "<button/>", "<ul/>", "<ol/>", "<li/>",
+ "<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
+ "<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"
+ ];
+ for (var i = 0; i < cloneTags.length; i++) {
+ var j = $(cloneTags[i]);
+ equals( j[0].tagName, j.clone()[0].tagName, 'Clone a &lt;' + cloneTags[i].substring(1));
+ }
+
+ // using contents will get comments regular, text, and comment nodes
+ var cl = $("#nonnodes").contents().clone();
+ ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
+});
+
+if (!isLocal) {
+test("clone() on XML nodes", function() {
+ expect(2);
+ stop();
+ $.get("data/dashboard.xml", function (xml) {
+ var root = $(xml.documentElement).clone();
+ $("tab:first", xml).text("origval");
+ $("tab:first", root).text("cloneval");
+ equals($("tab:first", xml).text(), "origval", "Check original XML node was correctly set");
+ equals($("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set");
+ start();
+ });
+});
+}
+
+test("is(String)", function() {
+ expect(26);
+ ok( $('#form').is('form'), 'Check for element: A form must be a form' );
+ ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
+ ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
+ ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
+ ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
+ ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
+ ok( $('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
+ ok( !$('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
+ ok( $('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
+ ok( !$('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
+ ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
+ ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
+ ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
+ ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
+ ok( $('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );
+ ok( !$('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );
+ ok( $('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );
+ ok( !$('#foo').is(':has(p):has(a):has(code):has(ol)'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
+ ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
+ ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
+ ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
+ ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
+
+ // test is() with comma-seperated expressions
+ ok( $('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
+ ok( $('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
+ ok( $('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
+ ok( $('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
+});
+
+test("$.extend(Object, Object)", function() {
+ expect(20);
+
+ var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
+ optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
+ merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
+ deep1 = { foo: { bar: true } },
+ deep1copy = { foo: { bar: true } },
+ deep2 = { foo: { baz: true }, foo2: document },
+ deep2copy = { foo: { baz: true }, foo2: document },
+ deepmerged = { foo: { bar: true, baz: true }, foo2: document };
+
+ jQuery.extend(settings, options);
+ isObj( settings, merged, "Check if extended: settings must be extended" );
+ isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
+
+ jQuery.extend(settings, null, options);
+ isObj( settings, merged, "Check if extended: settings must be extended" );
+ isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
+
+ jQuery.extend(true, deep1, deep2);
+ isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
+ isObj( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
+ equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
+
+ var nullUndef;
+ nullUndef = jQuery.extend({}, options, { xnumber2: null });
+ ok( nullUndef.xnumber2 === null, "Check to make sure null values are copied");
+
+ nullUndef = jQuery.extend({}, options, { xnumber2: undefined });
+ ok( nullUndef.xnumber2 === options.xnumber2, "Check to make sure undefined values are not copied");
+
+ nullUndef = jQuery.extend({}, options, { xnumber0: null });
+ ok( nullUndef.xnumber0 === null, "Check to make sure null values are inserted");
+
+ var target = {};
+ var recursive = { foo:target, bar:5 };
+ jQuery.extend(true, target, recursive);
+ isObj( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
+
+ var ret = jQuery.extend(true, { foo: [] }, { foo: [0] } ); // 1907
+ equals( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
+
+ var ret = jQuery.extend(true, { foo: "1,2,3" }, { foo: [1, 2, 3] } );
+ ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
+
+ var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
+ ok( typeof ret.foo !== 'undefined', "Make sure a null value doesn't crash with deep extend, for #1908" );
+
+ var obj = { foo:null };
+ jQuery.extend(true, obj, { foo:"notnull" } );
+ equals( obj.foo, "notnull", "Make sure a null value can be overwritten" );
+
+ function func() {}
+ jQuery.extend(func, { key: "value" } );
+ equals( func.key, "value", "Verify a function can be extended" );
+
+ var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ options1 = { xnumber2: 1, xstring2: "x" },
+ options1Copy = { xnumber2: 1, xstring2: "x" },
+ options2 = { xstring2: "xx", xxx: "newstringx" },
+ options2Copy = { xstring2: "xx", xxx: "newstringx" },
+ merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
+
+ var settings = jQuery.extend({}, defaults, options1, options2);
+ isObj( settings, merged2, "Check if extended: settings must be extended" );
+ isObj( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
+ isObj( options1, options1Copy, "Check if not modified: options1 must not be modified" );
+ isObj( options2, options2Copy, "Check if not modified: options2 must not be modified" );
+});
+
+test("val()", function() {
+ expect(4);
+ equals( $("#text1").val(), "Test", "Check for value of input element" );
+ equals( !$("#text1").val(), "", "Check for value of input element" );
+ // ticket #1714 this caused a JS error in IE
+ equals( $("#first").val(), "", "Check a paragraph element to see if it has a value" );
+ ok( $([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
+});
+
+test("val(String)", function() {
+ expect(4);
+ document.getElementById('text1').value = "bla";
+ equals( $("#text1").val(), "bla", "Check for modified value of input element" );
+ $("#text1").val('test');
+ ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
+
+ $("#select1").val("3");
+ equals( $("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.val("asdf");
+ equals( j.val(), "asdf", "Check node,textnode,comment with val()" );
+ j.removeAttr("value");
+});
+
+var scriptorder = 0;
+
+test("html(String)", function() {
+ expect(11);
+ var div = $("#main > div");
+ div.html("<b>test</b>");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).childNodes.length != 1 ) pass = false;
+ }
+ ok( pass, "Set HTML" );
+
+ reset();
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.html("<b>bold</b>");
+
+ // this is needed, or the expando added by jQuery unique will yield a different html
+ j.find('b').removeData();
+ equals( j.html().toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
+
+ $("#main").html("<select/>");
+ $("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");
+ equals( $("#main select").val(), "O2", "Selected option correct" );
+
+ stop();
+
+ $("#main").html('<script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');
+
+ $("#main").html('foo <form><script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');
+
+ // it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959
+ $("#main").html("<script>equals(scriptorder++, 0, 'Script is executed in order');equals($('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(scriptorder++, 1, 'Script (nested) is executed in order');equals($('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(scriptorder++, 2, 'Script (unnested) is executed in order');equals($('#scriptorder').length, 1,'Execute after html')<\/script>");
+
+ setTimeout( start, 100 );
+});
+
+test("filter()", function() {
+ expect(6);
+ isSet( $("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
+ isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
+ isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
+ isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ equals( j.filter("span").length, 1, "Check node,textnode,comment to filter the one span" );
+ equals( j.filter("[name]").length, 0, "Check node,textnode,comment to filter the one span" );
+});
+
+test("not()", function() {
+ expect(8);
+ equals( $("#main > p#ap > a").not("#google").length, 2, "not('selector')" );
+ equals( $("#main > p#ap > a").not(document.getElementById("google")).length, 2, "not(DOMElement)" );
+ isSet( $("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
+ isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
+ isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
+ equals( $("p").not(document.getElementsByTagName("p")).length, 0, "not(Array-like DOM collection)" );
+ isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");
+
+ var selects = $("#form select");
+ isSet( selects.not( selects[1] ), q("select1", "select3"), "filter out DOM element");
+});
+
+test("andSelf()", function() {
+ expect(4);
+ isSet( $("#en").siblings().andSelf().get(), q("sndp", "sap","en"), "Check for siblings and self" );
+ isSet( $("#foo").children().andSelf().get(), q("sndp", "en", "sap", "foo"), "Check for children and self" );
+ isSet( $("#en, #sndp").parent().andSelf().get(), q("foo","en","sndp"), "Check for parent and self" );
+ isSet( $("#groups").parents("p, div").andSelf().get(), q("ap", "main", "groups"), "Check for parents and self" );
+});
+
+test("siblings([String])", function() {
+ expect(5);
+ isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
+ isSet( $("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" );
+ isSet( $("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
+ isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" );
+ isSet( $("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" );
+});
+
+test("children([String])", function() {
+ expect(3);
+ isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
+ isSet( $("#foo").children(":has(code)").get(), q("sndp", "sap"), "Check for filtered children" );
+ isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );
+});
+
+test("parent([String])", function() {
+ expect(5);
+ equals( $("#groups").parent()[0].id, "ap", "Simple parent check" );
+ equals( $("#groups").parent("p")[0].id, "ap", "Filtered parent check" );
+ equals( $("#groups").parent("div").length, 0, "Filtered parent check, no match" );
+ equals( $("#groups").parent("div, p")[0].id, "ap", "Check for multiple filters" );
+ isSet( $("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" );
+});
+
+test("parents([String])", function() {
+ expect(5);
+ equals( $("#groups").parents()[0].id, "ap", "Simple parents check" );
+ equals( $("#groups").parents("p")[0].id, "ap", "Filtered parents check" );
+ equals( $("#groups").parents("div")[0].id, "main", "Filtered parents check2" );
+ isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );
+ isSet( $("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" );
+});
+
+test("next([String])", function() {
+ expect(4);
+ equals( $("#ap").next()[0].id, "foo", "Simple next check" );
+ equals( $("#ap").next("div")[0].id, "foo", "Filtered next check" );
+ equals( $("#ap").next("p").length, 0, "Filtered next check, no match" );
+ equals( $("#ap").next("div, p")[0].id, "foo", "Multiple filters" );
+});
+
+test("prev([String])", function() {
+ expect(4);
+ equals( $("#foo").prev()[0].id, "ap", "Simple prev check" );
+ equals( $("#foo").prev("p")[0].id, "ap", "Filtered prev check" );
+ equals( $("#foo").prev("div").length, 0, "Filtered prev check, no match" );
+ equals( $("#foo").prev("p, div")[0].id, "ap", "Multiple filters" );
+});
+
+test("show()", function() {
+ expect(15);
+ var pass = true, div = $("div");
+ div.show().each(function(){
+ if ( this.style.display == "none" ) pass = false;
+ });
+ ok( pass, "Show" );
+
+ $("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');
+ var test = {
+ "div" : "block",
+ "p" : "block",
+ "a" : "inline",
+ "code" : "inline",
+ "pre" : "block",
+ "span" : "inline",
+ "table" : $.browser.msie ? "block" : "table",
+ "thead" : $.browser.msie ? "block" : "table-header-group",
+ "tbody" : $.browser.msie ? "block" : "table-row-group",
+ "tr" : $.browser.msie ? "block" : "table-row",
+ "th" : $.browser.msie ? "block" : "table-cell",
+ "td" : $.browser.msie ? "block" : "table-cell",
+ "ul" : "block",
+ "li" : $.browser.msie ? "block" : "list-item"
+ };
+
+ $.each(test, function(selector, expected) {
+ var elem = $(selector, "#show-tests").show();
+ equals( elem.css("display"), expected, "Show using correct display type for " + selector );
+ });
+});
+
+test("addClass(String)", function() {
+ expect(2);
+ var div = $("div");
+ div.addClass("test");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
+ }
+ ok( pass, "Add Class" );
+
+ // using contents will get regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.addClass("asdf");
+ ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
+});
+
+test("removeClass(String) - simple", function() {
+ expect(4);
+ var div = $("div").addClass("test").removeClass("test"),
+ pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
+ }
+ ok( pass, "Remove Class" );
+
+ reset();
+ var div = $("div").addClass("test").addClass("foo").addClass("bar");
+ div.removeClass("test").removeClass("bar").removeClass("foo");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
+ }
+ ok( pass, "Remove multiple classes" );
+
+ reset();
+ var div = $("div:eq(0)").addClass("test").removeClass("");
+ ok( div.is('.test'), "Empty string passed to removeClass" );
+
+ // using contents will get regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.removeClass("asdf");
+ ok( !j.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
+});
+
+test("toggleClass(String)", function() {
+ expect(3);
+ var e = $("#firstp");
+ ok( !e.is(".test"), "Assert class not present" );
+ e.toggleClass("test");
+ ok( e.is(".test"), "Assert class present" );
+ e.toggleClass("test");
+ ok( !e.is(".test"), "Assert class not present" );
+});
+
+test("removeAttr(String", function() {
+ expect(1);
+ equals( $('#mark').removeAttr("class")[0].className, "", "remove class" );
+});
+
+test("text(String)", function() {
+ expect(4);
+ equals( $("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML, "&lt;div&gt;&lt;b&gt;Hello&lt;/b&gt; cruel world!&lt;/div&gt;", "Check escaped text" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.text("hi!");
+ equals( $(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
+ equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
+ equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
+});
+
+test("$.each(Object,Function)", function() {
+ expect(12);
+ $.each( [0,1,2], function(i, n){
+ equals( i, n, "Check array iteration" );
+ });
+
+ $.each( [5,6,7], function(i, n){
+ equals( i, n - 5, "Check array iteration" );
+ });
+
+ $.each( { name: "name", lang: "lang" }, function(i, n){
+ equals( i, n, "Check object iteration" );
+ });
+
+ var total = 0;
+ jQuery.each([1,2,3], function(i,v){ total += v; });
+ equals( total, 6, "Looping over an array" );
+ total = 0;
+ jQuery.each([1,2,3], function(i,v){ total += v; if ( i == 1 ) return false; });
+ equals( total, 3, "Looping over an array, with break" );
+ total = 0;
+ jQuery.each({"a":1,"b":2,"c":3}, function(i,v){ total += v; });
+ equals( total, 6, "Looping over an object" );
+ total = 0;
+ jQuery.each({"a":3,"b":3,"c":3}, function(i,v){ total += v; return false; });
+ equals( total, 3, "Looping over an object, with break" );
+});
+
+test("$.prop", function() {
+ expect(2);
+ var handle = function() { return this.id };
+ equals( $.prop($("#ap")[0], handle), "ap", "Check with Function argument" );
+ equals( $.prop($("#ap")[0], "value"), "value", "Check with value argument" );
+});
+
+test("$.className", function() {
+ expect(6);
+ var x = $("<p>Hi</p>")[0];
+ var c = $.className;
+ c.add(x, "hi");
+ equals( x.className, "hi", "Check single added class" );
+ c.add(x, "foo bar");
+ equals( x.className, "hi foo bar", "Check more added classes" );
+ c.remove(x);
+ equals( x.className, "", "Remove all classes" );
+ c.add(x, "hi foo bar");
+ c.remove(x, "foo");
+ equals( x.className, "hi bar", "Check removal of one class" );
+ ok( c.has(x, "hi"), "Check has1" );
+ ok( c.has(x, "bar"), "Check has2" );
+});
+
+test("$.data", function() {
+ expect(5);
+ var div = $("#foo")[0];
+ equals( jQuery.data(div, "test"), undefined, "Check for no data exists" );
+ jQuery.data(div, "test", "success");
+ equals( jQuery.data(div, "test"), "success", "Check for added data" );
+ jQuery.data(div, "test", "overwritten");
+ equals( jQuery.data(div, "test"), "overwritten", "Check for overwritten data" );
+ jQuery.data(div, "test", undefined);
+ equals( jQuery.data(div, "test"), "overwritten", "Check that data wasn't removed");
+ jQuery.data(div, "test", null);
+ ok( jQuery.data(div, "test") === null, "Check for null data");
+});
+
+test(".data()", function() {
+ expect(18);
+ var div = $("#foo");
+ equals( div.data("test"), undefined, "Check for no data exists" );
+ div.data("test", "success");
+ equals( div.data("test"), "success", "Check for added data" );
+ div.data("test", "overwritten");
+ equals( div.data("test"), "overwritten", "Check for overwritten data" );
+ div.data("test", undefined);
+ equals( div.data("test"), "overwritten", "Check that data wasn't removed");
+ div.data("test", null);
+ ok( div.data("test") === null, "Check for null data");
+
+ div.data("test", "overwritten");
+ var hits = {test:0}, gets = {test:0};
+
+ div
+ .bind("setData",function(e,key,value){ hits[key] += value; })
+ .bind("setData.foo",function(e,key,value){ hits[key] += value; })
+ .bind("getData",function(e,key){ gets[key] += 1; })
+ .bind("getData.foo",function(e,key){ gets[key] += 3; });
+
+ div.data("test.foo", 2);
+ equals( div.data("test"), "overwritten", "Check for original data" );
+ equals( div.data("test.foo"), 2, "Check for namespaced data" );
+ equals( div.data("test.bar"), "overwritten", "Check for unmatched namespace" );
+ equals( hits.test, 2, "Check triggered setter functions" );
+ equals( gets.test, 5, "Check triggered getter functions" );
+
+ hits.test = 0;
+ gets.test = 0;
+
+ div.data("test", 1);
+ equals( div.data("test"), 1, "Check for original data" );
+ equals( div.data("test.foo"), 2, "Check for namespaced data" );
+ equals( div.data("test.bar"), 1, "Check for unmatched namespace" );
+ equals( hits.test, 1, "Check triggered setter functions" );
+ equals( gets.test, 5, "Check triggered getter functions" );
+
+ hits.test = 0;
+ gets.test = 0;
+
+ div
+ .bind("getData",function(e,key){ return key + "root"; })
+ .bind("getData.foo",function(e,key){ return key + "foo"; });
+
+ equals( div.data("test"), "testroot", "Check for original data" );
+ equals( div.data("test.foo"), "testfoo", "Check for namespaced data" );
+ equals( div.data("test.bar"), "testroot", "Check for unmatched namespace" );
+});
+
+test("$.removeData", function() {
+ expect(1);
+ var div = $("#foo")[0];
+ jQuery.data(div, "test", "testing");
+ jQuery.removeData(div, "test");
+ equals( jQuery.data(div, "test"), undefined, "Check removal of data" );
+});
+
+test(".removeData()", function() {
+ expect(6);
+ var div = $("#foo");
+ div.data("test", "testing");
+ div.removeData("test");
+ equals( div.data("test"), undefined, "Check removal of data" );
+
+ div.data("test", "testing");
+ div.data("test.foo", "testing2");
+ div.removeData("test.bar");
+ equals( div.data("test.foo"), "testing2", "Make sure data is intact" );
+ equals( div.data("test"), "testing", "Make sure data is intact" );
+
+ div.removeData("test");
+ equals( div.data("test.foo"), "testing2", "Make sure data is intact" );
+ equals( div.data("test"), undefined, "Make sure data is intact" );
+
+ div.removeData("test.foo");
+ equals( div.data("test.foo"), undefined, "Make sure data is intact" );
+});
+
+test("remove()", function() {
+ expect(6);
+ $("#ap").children().remove();
+ ok( $("#ap").text().length > 10, "Check text is not removed" );
+ equals( $("#ap").children().length, 0, "Check remove" );
+
+ reset();
+ $("#ap").children().remove("a");
+ ok( $("#ap").text().length > 10, "Check text is not removed" );
+ equals( $("#ap").children().length, 1, "Check filtered remove" );
+
+ // using contents will get comments regular, text, and comment nodes
+ equals( $("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
+ $("#nonnodes").contents().remove();
+ equals( $("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
+});
+
+test("empty()", function() {
+ expect(3);
+ equals( $("#ap").children().empty().text().length, 0, "Check text is removed" );
+ equals( $("#ap").children().length, 4, "Check elements are not removed" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var j = $("#nonnodes").contents();
+ j.empty();
+ equals( j.html(), "", "Check node,textnode,comment empty works" );
+});
+
+test("slice()", function() {
+ expect(5);
+ isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );
+ isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );
+ isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
+ isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
+
+ isSet( $("#ap a").eq(1), q("groups"), "eq(1)" );
+});
+
+test("map()", function() {
+ expect(2);//expect(6);
+
+ isSet(
+ $("#ap").map(function(){
+ return $(this).find("a").get();
+ }),
+ q("google", "groups", "anchor1", "mark"),
+ "Array Map"
+ );
+
+ isSet(
+ $("#ap > a").map(function(){
+ return this.parentNode;
+ }),
+ q("ap","ap","ap"),
+ "Single Map"
+ );
+
+ return;//these haven't been accepted yet
+
+ //for #2616
+ var keys = $.map( {a:1,b:2}, function( v, k ){
+ return k;
+ }, [ ] );
+
+ equals( keys.join(""), "ab", "Map the keys from a hash to an array" );
+
+ var values = $.map( {a:1,b:2}, function( v, k ){
+ return v;
+ }, [ ] );
+
+ equals( values.join(""), "12", "Map the values from a hash to an array" );
+
+ var scripts = document.getElementsByTagName("script");
+ var mapped = $.map( scripts, function( v, k ){
+ return v;
+ }, {length:0} );
+
+ equals( mapped.length, scripts.length, "Map an array(-like) to a hash" );
+
+ var flat = $.map( Array(4), function( v, k ){
+ return k % 2 ? k : [k,k,k];//try mixing array and regular returns
+ });
+
+ equals( flat.join(""), "00012223", "try the new flatten technique(#2616)" );
+});
+
+test("contents()", function() {
+ expect(12);
+ equals( $("#ap").contents().length, 9, "Check element contents" );
+ ok( $("#iframe").contents()[0], "Check existance of IFrame document" );
+ var ibody = $("#loadediframe").contents()[0].body;
+ ok( ibody, "Check existance of IFrame body" );
+
+ equals( $("span", ibody).text(), "span text", "Find span in IFrame and check its text" );
+
+ $(ibody).append("<div>init text</div>");
+ equals( $("div", ibody).length, 2, "Check the original div and the new div are in IFrame" );
+
+ equals( $("div:last", ibody).text(), "init text", "Add text to div in IFrame" );
+
+ $("div:last", ibody).text("div text");
+ equals( $("div:last", ibody).text(), "div text", "Add text to div in IFrame" );
+
+ $("div:last", ibody).remove();
+ equals( $("div", ibody).length, 1, "Delete the div and check only one div left in IFrame" );
+
+ equals( $("div", ibody).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );
+
+ $("<table/>", ibody).append("<tr><td>cell</td></tr>").appendTo(ibody);
+ $("table", ibody).remove();
+ equals( $("div", ibody).length, 1, "Check for JS error on add and delete of a table in IFrame" );
+
+ // using contents will get comments regular, text, and comment nodes
+ var c = $("#nonnodes").contents().contents();
+ equals( c.length, 1, "Check node,textnode,comment contents is just one" );
+ equals( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
+});
+
+test("$.makeArray", function(){
+ expect(15);
+
+ equals( $.makeArray($('html>*'))[0].nodeName, "HEAD", "Pass makeArray a jQuery object" );
+
+ equals( $.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
+
+ equals( (function(){ return $.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
+
+ equals( $.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );
+
+ equals( $.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" );
+
+ equals( $.makeArray( 0 )[0], 0 , "Pass makeArray a number" );
+
+ equals( $.makeArray( "foo" )[0], "foo", "Pass makeArray a string" );
+
+ equals( $.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" );
+
+ equals( $.makeArray( document.createElement("div") )[0].nodeName, "DIV", "Pass makeArray a single node" );
+
+ equals( $.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" );
+
+ equals( $.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "HEAD", "Pass makeArray a childNodes array" );
+
+ //function, is tricky as it has length
+ equals( $.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );
+ //window, also has length
+ equals( $.makeArray(window)[0], window, "Pass makeArray the window" );
+
+ equals( $.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
+
+ ok( $.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
+});
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/dimensions.js b/dom/tests/mochitest/ajax/jquery/test/unit/dimensions.js
new file mode 100644
index 0000000000..aac1655f51
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/dimensions.js
@@ -0,0 +1,86 @@
+module("dimensions");
+
+test("innerWidth()", function() {
+ expect(3);
+
+ var $div = $("#nothiddendiv");
+ // set styles
+ $div.css({
+ margin: 10,
+ border: "2px solid #fff",
+ width: 30
+ });
+
+ equals($div.innerWidth(), 30, "Test with margin and border");
+ $div.css("padding", "20px");
+ equals($div.innerWidth(), 70, "Test with margin, border and padding");
+ $div.hide();
+ equals($div.innerWidth(), 70, "Test hidden div");
+
+ // reset styles
+ $div.css({ display: "", border: "", padding: "", width: "", height: "" });
+});
+
+test("innerHeight()", function() {
+ expect(3);
+
+ var $div = $("#nothiddendiv");
+ // set styles
+ $div.css({
+ margin: 10,
+ border: "2px solid #fff",
+ height: 30
+ });
+
+ equals($div.innerHeight(), 30, "Test with margin and border");
+ $div.css("padding", "20px");
+ equals($div.innerHeight(), 70, "Test with margin, border and padding");
+ $div.hide();
+ equals($div.innerHeight(), 70, "Test hidden div");
+
+ // reset styles
+ $div.css({ display: "", border: "", padding: "", width: "", height: "" });
+});
+
+test("outerWidth()", function() {
+ expect(6);
+
+ var $div = $("#nothiddendiv");
+ $div.css("width", 30);
+
+ equals($div.outerWidth(), 30, "Test with only width set");
+ $div.css("padding", "20px");
+ equals($div.outerWidth(), 70, "Test with padding");
+ $div.css("border", "2px solid #fff");
+ equals($div.outerWidth(), 74, "Test with padding and border");
+ $div.css("margin", "10px");
+ equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
+ $div.css("position", "absolute");
+ equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
+ $div.hide();
+ equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
+
+ // reset styles
+ $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
+});
+
+test("outerHeight()", function() {
+ expect(6);
+
+ var $div = $("#nothiddendiv");
+ $div.css("height", 30);
+
+ equals($div.outerHeight(), 30, "Test with only width set");
+ $div.css("padding", "20px");
+ equals($div.outerHeight(), 70, "Test with padding");
+ $div.css("border", "2px solid #fff");
+ equals($div.outerHeight(), 74, "Test with padding and border");
+ $div.css("margin", "10px");
+ equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
+ equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
+ $div.hide();
+ equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
+
+ // reset styles
+ $div.css({ display: "", border: "", padding: "", width: "", height: "" });
+}); \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/event.js b/dom/tests/mochitest/ajax/jquery/test/unit/event.js
new file mode 100644
index 0000000000..c393f6d62a
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/event.js
@@ -0,0 +1,348 @@
+module("event");
+
+test("bind(), with data", function() {
+ expect(3);
+ var handler = function(event) {
+ ok( event.data, "bind() with data, check passed data exists" );
+ equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
+ };
+ $("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
+
+ ok( !jQuery.data($("#firstp")[0], "events"), "Event handler unbound when using data." );
+});
+
+test("bind(), with data, trigger with data", function() {
+ expect(4);
+ var handler = function(event, data) {
+ ok( event.data, "check passed data exists" );
+ equals( event.data.foo, "bar", "Check value of passed data" );
+ ok( data, "Check trigger data" );
+ equals( data.bar, "foo", "Check value of trigger data" );
+ };
+ $("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).unbind("click", handler);
+});
+
+test("bind(), multiple events at once", function() {
+ expect(2);
+ var clickCounter = 0,
+ mouseoverCounter = 0;
+ var handler = function(event) {
+ if (event.type == "click")
+ clickCounter += 1;
+ else if (event.type == "mouseover")
+ mouseoverCounter += 1;
+ };
+ $("#firstp").bind("click mouseover", handler).trigger("click").trigger("mouseover");
+ equals( clickCounter, 1, "bind() with multiple events at once" );
+ equals( mouseoverCounter, 1, "bind() with multiple events at once" );
+});
+
+test("bind(), no data", function() {
+ expect(1);
+ var handler = function(event) {
+ ok ( !event.data, "Check that no data is added to the event object" );
+ };
+ $("#firstp").bind("click", handler).trigger("click");
+});
+
+test("bind(), iframes", function() {
+ // events don't work with iframes, see #939 - this test fails in IE because of contentDocument
+ // var doc = document.getElementById("iframe").contentDocument;
+ //
+ // doc.body.innerHTML = "<input type='text'/>";
+ //
+ // var input = doc.getElementsByTagName("input")[0];
+ //
+ // $(input).bind("click",function() {
+ // ok( true, "Binding to element inside iframe" );
+ // }).click();
+});
+
+test("bind(), trigger change on select", function() {
+ expect(3);
+ var counter = 0;
+ function selectOnChange(event) {
+ equals( event.data, counter++, "Event.data is not a global event object" );
+ };
+ $("#form select").each(function(i){
+ $(this).bind('change', i, selectOnChange);
+ }).trigger('change');
+});
+
+test("bind(), namespaced events, cloned events", function() {
+ expect(6);
+
+ $("#firstp").bind("custom.test",function(e){
+ ok(true, "Custom event triggered");
+ });
+
+ $("#firstp").bind("click",function(e){
+ ok(true, "Normal click triggered");
+ });
+
+ $("#firstp").bind("click.test",function(e){
+ ok(true, "Namespaced click triggered");
+ });
+
+ // Trigger both bound fn (2)
+ $("#firstp").trigger("click");
+
+ // Trigger one bound fn (1)
+ $("#firstp").trigger("click.test");
+
+ // Remove only the one fn
+ $("#firstp").unbind("click.test");
+
+ // Trigger the remaining fn (1)
+ $("#firstp").trigger("click");
+
+ // Remove the remaining fn
+ $("#firstp").unbind(".test");
+
+ // Trigger the remaining fn (0)
+ $("#firstp").trigger("custom");
+
+ // using contents will get comments regular, text, and comment nodes
+ $("#nonnodes").contents().bind("tester", function () {
+ equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" );
+ }).trigger("tester");
+
+ // Make sure events stick with appendTo'd elements (which are cloned) #2027
+ $("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("p");
+ ok( $("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
+});
+
+test("trigger() shortcuts", function() {
+ expect(6);
+ $('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {
+ var close = $('spanx', this); // same with $(this).find('span');
+ equals( close.length, 0, "Context element does not exist, length must be zero" );
+ ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
+ return false;
+ }).click();
+
+ $("#check1").click(function() {
+ ok( true, "click event handler for checkbox gets fired twice, see #815" );
+ }).click();
+
+ var counter = 0;
+ $('#firstp')[0].onclick = function(event) {
+ counter++;
+ };
+ $('#firstp').click();
+ equals( counter, 1, "Check that click, triggers onclick event handler also" );
+
+ var clickCounter = 0;
+ $('#simon1')[0].onclick = function(event) {
+ clickCounter++;
+ };
+ $('#simon1').click();
+ equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
+
+ $('<img />').load(function(){
+ ok( true, "Trigger the load event, using the shortcut .load() (#2819)");
+ }).load();
+});
+
+test("unbind(event)", function() {
+ expect(8);
+ var el = $("#firstp");
+ el.click(function() {
+ ok( true, "Fake normal bind" );
+ });
+ el.click(function(event) {
+ el.unbind(event);
+ ok( true, "Fake onebind" );
+ });
+ el.click().click();
+
+ el.click(function() { return; });
+ el.unbind('click');
+ ok( !el[0].onclick, "Handler is removed" ); // Bug #964
+
+ el.click(function() { return; });
+ el.unbind('change',function(){ return; });
+ for (var ret in jQuery.data(el[0], "events")['click']) break;
+ ok( ret, "Extra handlers weren't accidentally removed." );
+
+ el.unbind('click');
+ ok( !jQuery.data(el[0], "events"), "Removed the events expando after all handlers are unbound." );
+
+ reset();
+ var clickCounter = (mouseoverCounter = 0);
+ var handler = function(event) {
+ if (event.type == "click")
+ clickCounter += 1;
+ else if (event.type == "mouseover")
+ mouseoverCounter += 1;
+ };
+ $("#firstp").bind("click mouseover", handler).unbind("click mouseover", handler).trigger("click").trigger("mouseover");
+ equals( clickCounter, 0, "unbind() with multiple events at once" );
+ equals( mouseoverCounter, 0, "unbind() with multiple events at once" );
+});
+
+test("trigger(event, [data], [fn])", function() {
+ expect(67);
+
+ var handler = function(event, a, b, c) {
+ equals( event.type, "click", "check passed data" );
+ equals( a, 1, "check passed data" );
+ equals( b, "2", "check passed data" );
+ equals( c, "abc", "check passed data" );
+ return "test";
+ };
+
+ var handler2 = function(a, b, c) {
+ equals( a, 1, "check passed data" );
+ equals( b, "2", "check passed data" );
+ equals( c, "abc", "check passed data" );
+ return false;
+ };
+
+ var handler3 = function(a, b, c, v) {
+ equals( a, 1, "check passed data" );
+ equals( b, "2", "check passed data" );
+ equals( c, "abc", "check passed data" );
+ equals( v, "test", "check current value" );
+ return "newVal";
+ };
+
+ var handler4 = function(a, b, c, v) {
+ equals( a, 1, "check passed data" );
+ equals( b, "2", "check passed data" );
+ equals( c, "abc", "check passed data" );
+ equals( v, "test", "check current value" );
+ };
+
+ // Simulate a "native" click
+ $("#firstp")[0].click = function(){
+ ok( true, "Native call was triggered" );
+ };
+
+ // Triggers handlrs and native
+ // Trigger 5
+ $("#firstp").bind("click", handler).trigger("click", [1, "2", "abc"]);
+
+ // Triggers handlers, native, and extra fn
+ // Triggers 9
+ $("#firstp").trigger("click", [1, "2", "abc"], handler4);
+
+ // Simulate a "native" click
+ $("#firstp")[0].click = function(){
+ ok( false, "Native call was triggered" );
+ };
+
+ // Triggers handlers, native, and extra fn
+ // Triggers 7
+ $("#firstp").trigger("click", [1, "2", "abc"], handler2);
+
+ // Trigger only the handlers (no native)
+ // Triggers 5
+ equals( $("#firstp").triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );
+
+ // Trigger only the handlers (no native) and extra fn
+ // Triggers 8
+ equals( $("#firstp").triggerHandler("click", [1, "2", "abc"], handler2), false, "Verify handler response" );
+
+ // Build fake click event to pass in
+ var eventObj = jQuery.event.fix({ type: "foo", target: document.body });
+
+ // Trigger only the handlers (no native), with external event obj
+ // Triggers 5
+ equals( $("#firstp").triggerHandler("click", [eventObj, 1, "2", "abc"]), "test", "Verify handler response" );
+
+ // Trigger only the handlers (no native) and extra fn, with external event obj
+ // Triggers 9
+ eventObj = jQuery.event.fix({ type: "foo", target: document.body });
+ equals( $("#firstp").triggerHandler("click", [eventObj, 1, "2", "abc"], handler), "test", "Verify handler response" );
+
+ var pass = true;
+ try {
+ $('input:first')
+ .hide()
+ .trigger('focus');
+ } catch(e) {
+ pass = false;
+ }
+ ok( pass, "Trigger focus on hidden element" );
+
+ // have the extra handler override the return
+ // Triggers 9
+ equals( $("#firstp").triggerHandler("click", [1, "2", "abc"], handler3), "newVal", "Verify triggerHandler return is overwritten by extra function" );
+
+ // have the extra handler leave the return value alone
+ // Triggers 9
+ equals( $("#firstp").triggerHandler("click", [1, "2", "abc"], handler4), "test", "Verify triggerHandler return is not overwritten by extra function" );
+});
+
+test("toggle(Function, Function, ...)", function() {
+ expect(11);
+
+ var count = 0,
+ fn1 = function(e) { count++; },
+ fn2 = function(e) { count--; },
+ preventDefault = function(e) { e.preventDefault() },
+ link = $('#mark');
+ link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
+ equals( count, 1, "Check for toggle(fn, fn)" );
+
+ $("#firstp").toggle(function () {
+ equals(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" )
+ }, function() {}).trigger("click", [ 1, 2, 3 ]);
+
+ var first = 0;
+ $("#simon1").one("click", function() {
+ ok( true, "Execute event only once" );
+ $(this).toggle(function() {
+ equals( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
+ }, function() {
+ equals( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
+ });
+ return false;
+ }).click().click().click();
+
+ var turn = 0;
+ var fns = [
+ function(){
+ turn = 1;
+ },
+ function(){
+ turn = 2;
+ },
+ function(){
+ turn = 3;
+ }
+ ];
+
+ var $div = $("<div>&nbsp;</div>").toggle( fns[0], fns[1], fns[2] );
+ $div.click();
+ equals( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1");
+ $div.click();
+ equals( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2");
+ $div.click();
+ equals( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3");
+ $div.click();
+ equals( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1");
+ $div.click();
+ equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
+
+ $div.unbind('click',fns[0]);
+ var data = $.data( $div[0], 'events' );
+ ok( !data, "Unbinding one function from toggle unbinds them all");
+});
+
+test("jQuery(function($) {})", function() {
+ stop();
+ jQuery(function($) {
+ equals(jQuery, $, "ready doesn't provide an event object, instead it provides a reference to the jQuery function, see http://docs.jquery.com/Events/ready#fn");
+ start();
+ });
+});
+
+test("event properties", function() {
+ stop();
+ $("#simon1").click(function(event) {
+ ok( event.timeStamp, "assert event.timeStamp is present" );
+ start();
+ }).click();
+});
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/fx.js b/dom/tests/mochitest/ajax/jquery/test/unit/fx.js
new file mode 100644
index 0000000000..77a54bf65c
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/fx.js
@@ -0,0 +1,435 @@
+module("fx");
+
+test("animate(Hash, Object, Function)", function() {
+ expect(1);
+ stop();
+ var hash = {opacity: 'show'};
+ var hashCopy = $.extend({}, hash);
+ $('#foo').animate(hash, 0, function() {
+ equals( hash.opacity, hashCopy.opacity, 'Check if animate changed the hash parameter' );
+ start();
+ });
+});
+
+/* Commented out because of bug 450190
+test("animate option (queue === false)", function () {
+ expect(1);
+ stop();
+
+ var order = [];
+
+ var $foo = $("#foo");
+ $foo.animate({width:'100px'}, 200, function () {
+ // should finish after unqueued animation so second
+ order.push(2);
+ });
+ $foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
+ // short duration and out of queue so should finish first
+ order.push(1);
+ }});
+ $foo.animate({height:'100px'}, 10, function() {
+ // queued behind the first animation so should finish third
+ order.push(3);
+ isSet( order, [ 1, 2, 3], "Animations finished in the correct order" );
+ start();
+ });
+});
+*/
+
+test("queue() defaults to 'fx' type", function () {
+ expect(2);
+ stop();
+
+ var $foo = $("#foo");
+ $foo.queue("fx", [ "sample", "array" ]);
+ var arr = $foo.queue();
+ isSet(arr, [ "sample", "array" ], "queue() got an array set with type 'fx'");
+ $foo.queue([ "another", "one" ]);
+ var arr = $foo.queue("fx");
+ isSet(arr, [ "another", "one" ], "queue('fx') got an array set with no type");
+ // clean up after test
+ $foo.queue([]);
+
+ start();
+});
+
+test("stop()", function() {
+ expect(3);
+ stop();
+
+ var $foo = $("#nothiddendiv");
+ var w = 0;
+ $foo.hide().width(200).width();
+
+ $foo.animate({ width:'show' }, 1000);
+ setTimeout(function(){
+ var nw = $foo.width();
+ ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
+ $foo.stop();
+
+ nw = $foo.width();
+ ok( nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+ setTimeout(function(){
+ equals( nw, $foo.width(), "The animation didn't continue" );
+ start();
+ }, 100);
+ }, 100);
+});
+
+test("stop() - several in queue", function() {
+// Merge from jquery test 1.3.2
+ expect(2);
+ stop();
+
+ var $foo = $("#nothiddendiv");
+ var w = 0;
+ $foo.hide().width(200).width();
+
+ $foo.animate({ width:'show' }, 1000);
+ $foo.animate({ width:'hide' }, 1000);
+ $foo.animate({ width:'show' }, 1000);
+ setTimeout(function(){
+ // Unreliable. See bug 484994.
+ // equals( $foo.queue().length, 3, "All 3 still in the queue" );
+ var nw = $foo.width();
+ ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
+ $foo.stop();
+
+ nw = $foo.width();
+ ok( nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+ // Merged from 1.3.2, commented out for being flaky in 1.3.2 test suite
+ //equals( $foo.queue().length, 2, "The next animation continued" );
+ $foo.stop(true);
+ start();
+ }, 100);
+});
+
+test("stop(clearQueue)", function() {
+ expect(4);
+ stop();
+
+ var $foo = $("#nothiddendiv");
+ var w = 0;
+ $foo.hide().width(200).width();
+
+ $foo.animate({ width:'show' }, 1000);
+ $foo.animate({ width:'hide' }, 1000);
+ $foo.animate({ width:'show' }, 1000);
+ setTimeout(function(){
+ var nw = $foo.width();
+ ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
+ $foo.stop(true);
+
+ nw = $foo.width();
+ ok( nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+
+ equals( $foo.queue().length, 0, "The animation queue was cleared" );
+ setTimeout(function(){
+ equals( nw, $foo.width(), "The animation didn't continue" );
+ start();
+ }, 100);
+ }, 100);
+});
+
+test("stop(clearQueue, gotoEnd)", function() {
+ // Merge from 1.3.2 - this test marked as being flaky
+ expect(1);
+ stop();
+
+ var $foo = $("#nothiddendiv");
+ var w = 0;
+ $foo.hide().width(200).width();
+
+ $foo.animate({ width:'show' }, 1000);
+ $foo.animate({ width:'hide' }, 1000);
+ $foo.animate({ width:'show' }, 1000);
+ $foo.animate({ width:'hide' }, 1000);
+ setTimeout(function(){
+ var nw = $foo.width();
+ ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
+ $foo.stop(false, true);
+
+ nw = $foo.width();
+ // Merge from 1.3.2 - marked as flaky in that release
+ //equals( nw, 200, "Stop() reset the animation" );
+
+ setTimeout(function(){
+ // Merge from 1.3.2 - marked as flaky in that release
+ //equals( $foo.queue().length, 3, "The next animation continued" );
+ $foo.stop(true);
+ start();
+ }, 100);
+ }, 100);
+});
+
+test("toggle()", function() {
+ expect(3);
+ var x = $("#foo");
+ ok( x.is(":visible"), "is visible" );
+ x.toggle();
+ ok( x.is(":hidden"), "is hidden" );
+ x.toggle();
+ ok( x.is(":visible"), "is visible again" );
+});
+
+var visible = {
+ Normal: function(elem){},
+ "CSS Hidden": function(elem){
+ $(this).addClass("hidden");
+ },
+ "JS Hidden": function(elem){
+ $(this).hide();
+ }
+};
+
+var from = {
+ "CSS Auto": function(elem,prop){
+ $(elem).addClass("auto" + prop)
+ .text("This is a long string of text.");
+ return "";
+ },
+ "JS Auto": function(elem,prop){
+ $(elem).css(prop,"auto")
+ .text("This is a long string of text.");
+ return "";
+ },
+ "CSS 100": function(elem,prop){
+ $(elem).addClass("large" + prop);
+ return "";
+ },
+ "JS 100": function(elem,prop){
+ $(elem).css(prop,prop == "opacity" ? 1 : "100px");
+ return prop == "opacity" ? 1 : 100;
+ },
+ "CSS 50": function(elem,prop){
+ $(elem).addClass("med" + prop);
+ return "";
+ },
+ "JS 50": function(elem,prop){
+ $(elem).css(prop,prop == "opacity" ? 0.50 : "50px");
+ return prop == "opacity" ? 0.5 : 50;
+ },
+ "CSS 0": function(elem,prop){
+ $(elem).addClass("no" + prop);
+ return "";
+ },
+ "JS 0": function(elem,prop){
+ $(elem).css(prop,prop == "opacity" ? 0 : "0px");
+ return 0;
+ }
+};
+
+var to = {
+ "show": function(elem,prop){
+ $(elem).hide().addClass("wide"+prop);
+ return "show";
+ },
+ "hide": function(elem,prop){
+ $(elem).addClass("wide"+prop);
+ return "hide";
+ },
+ "100": function(elem,prop){
+ $(elem).addClass("wide"+prop);
+ return prop == "opacity" ? 1 : 100;
+ },
+ "50": function(elem,prop){
+ return prop == "opacity" ? 0.50 : 50;
+ },
+ "0": function(elem,prop){
+ $(elem).addClass("noback");
+ return 0;
+ }
+};
+
+function checkOverflowDisplay(){
+ var o = jQuery.css( this, "overflow" );
+
+ equals(o, "visible", "Overflow should be visible: " + o);
+ equals(jQuery.css( this, "display" ), "inline", "Display shouldn't be tampered with.");
+
+ start();
+}
+
+test("JS Overflow and Display", function() {
+ expect(2);
+ stop();
+ makeTest( "JS Overflow and Display" )
+ .addClass("widewidth")
+ .css({ overflow: "visible", display: "inline" })
+ .addClass("widewidth")
+ .text("Some sample text.")
+ .before("text before")
+ .after("text after")
+ .animate({ opacity: 0.5 }, "slow", checkOverflowDisplay);
+});
+
+test("CSS Overflow and Display", function() {
+ expect(2);
+ stop();
+ makeTest( "CSS Overflow and Display" )
+ .addClass("overflow inline")
+ .addClass("widewidth")
+ .text("Some sample text.")
+ .before("text before")
+ .after("text after")
+ .animate({ opacity: 0.5 }, "slow", checkOverflowDisplay);
+});
+
+jQuery.each( from, function(fn, f){
+ jQuery.each( to, function(tn, t){
+ test(fn + " to " + tn, function() {
+ var elem = makeTest( fn + " to " + tn );
+
+ var t_w = t( elem, "width" );
+ var f_w = f( elem, "width" );
+ var t_h = t( elem, "height" );
+ var f_h = f( elem, "height" );
+ var t_o = t( elem, "opacity" );
+ var f_o = f( elem, "opacity" );
+
+ var num = 0;
+
+ if ( t_h == "show" ) num++;
+ if ( t_w == "show" ) num++;
+ if ( t_w == "hide"||t_w == "show" ) num++;
+ if ( t_h == "hide"||t_h == "show" ) num++;
+ if ( t_o == "hide"||t_o == "show" ) num++;
+ if ( t_w == "hide" ) num++;
+ if ( t_o.constructor == Number ) num += 2;
+ if ( t_w.constructor == Number ) num += 2;
+ if ( t_h.constructor == Number ) num +=2;
+
+ expect(num);
+ stop();
+
+ var anim = { width: t_w, height: t_h, opacity: t_o };
+
+ elem.animate(anim, 50, function(){
+ if ( t_w == "show" )
+ equals( this.style.display, "block", "Showing, display should block: " + this.style.display);
+
+ if ( t_w == "hide"||t_w == "show" )
+ equals(this.style.width.indexOf(f_w), 0, "Width must be reset to " + f_w + ": " + this.style.width);
+
+ if ( t_h == "hide"||t_h == "show" )
+ equals(this.style.height.indexOf(f_h), 0, "Height must be reset to " + f_h + ": " + this.style.height);
+
+ var cur_o = jQuery.attr(this.style, "opacity");
+ if ( cur_o !== "" ) cur_o = parseFloat( cur_o );
+
+ if ( t_o == "hide"||t_o == "show" )
+ equals(cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o);
+
+ if ( t_w == "hide" )
+ equals(this.style.display, "none", "Hiding, display should be none: " + this.style.display);
+
+ if ( t_o.constructor == Number ) {
+ equals(cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o);
+
+ ok(jQuery.curCSS(this, "opacity") != "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
+ }
+
+ if ( t_w.constructor == Number ) {
+ equals(this.style.width, t_w + "px", "Final width should be " + t_w + ": " + this.style.width);
+
+ var cur_w = jQuery.css(this,"width");
+
+ ok(this.style.width != "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w);
+ }
+
+ if ( t_h.constructor == Number ) {
+ equals(this.style.height, t_h + "px", "Final height should be " + t_h + ": " + this.style.height);
+
+ var cur_h = jQuery.css(this,"height");
+
+ ok(this.style.height != "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w);
+ }
+
+ if ( t_h == "show" ) {
+ var old_h = jQuery.curCSS(this, "height");
+ $(elem).append("<br/>Some more text<br/>and some more...");
+ ok(old_h != jQuery.css(this, "height" ), "Make sure height is auto.");
+ }
+
+ start();
+ });
+ });
+ });
+});
+
+var check = ['opacity','height','width','display','overflow'];
+
+jQuery.fn.saveState = function(){
+ expect(check.length);
+ stop();
+ return this.each(function(){
+ var self = this;
+ self.save = {};
+ jQuery.each(check, function(i,c){
+ self.save[c] = jQuery.css(self,c);
+ });
+ });
+};
+
+function checkState(){
+ var self = this;
+ jQuery.each(this.save, function(c,v){
+ var cur = jQuery.css(self,c);
+ equals( v, cur, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
+ });
+ start();
+}
+
+// Chaining Tests
+test("Chain fadeOut fadeIn", function() {
+ $('#fadein div').saveState().fadeOut('fast').fadeIn('fast',checkState);
+});
+test("Chain fadeIn fadeOut", function() {
+ $('#fadeout div').saveState().fadeIn('fast').fadeOut('fast',checkState);
+});
+
+test("Chain hide show", function() {
+ $('#show div').saveState().hide('fast').show('fast',checkState);
+});
+test("Chain show hide", function() {
+ $('#hide div').saveState().show('fast').hide('fast',checkState);
+});
+
+test("Chain toggle in", function() {
+ $('#togglein div').saveState().toggle('fast').toggle('fast',checkState);
+});
+test("Chain toggle out", function() {
+ $('#toggleout div').saveState().toggle('fast').toggle('fast',checkState);
+});
+
+test("Chain slideDown slideUp", function() {
+ $('#slidedown div').saveState().slideDown('fast').slideUp('fast',checkState);
+});
+test("Chain slideUp slideDown", function() {
+ $('#slideup div').saveState().slideUp('fast').slideDown('fast',checkState);
+});
+
+test("Chain slideToggle in", function() {
+ $('#slidetogglein div').saveState().slideToggle('fast').slideToggle('fast',checkState);
+});
+test("Chain slideToggle out", function() {
+ $('#slidetoggleout div').saveState().slideToggle('fast').slideToggle('fast',checkState);
+});
+
+function makeTest( text ){
+ var elem = $("<div></div>")
+ .attr("id", "test" + makeTest.id++)
+ .addClass("box");
+
+ $("<h4></h4>")
+ .text( text )
+ .appendTo("#fx-tests")
+ .click(function(){
+ $(this).next().toggle();
+ })
+ .after( elem );
+
+ return elem;
+}
+
+makeTest.id = 1;
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/offset.js b/dom/tests/mochitest/ajax/jquery/test/unit/offset.js
new file mode 100644
index 0000000000..55c3c436a6
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/offset.js
@@ -0,0 +1,164 @@
+module("offset");
+
+// opens a new window to run the tests against
+var testwin = function(name, fn) {
+ testwin[name] = load_offset_fixture(name);
+ var interval = setInterval(function() {
+ if (testwin[name] && testwin[name].$ && testwin[name].$.isReady) {
+ clearInterval(interval);
+ test(name, fn);
+ }
+ }, 0);
+
+ function load_offset_fixture(name) {
+ var win = window.open( "./data/offset/" + name + ".html?num"+parseInt(Math.random()*1000), name, 'left=0,top=0,width=500,height=500,toolbar=1,resizable=0' );
+ if ( !win ) {
+ alert("Please disable your popup blocker for the offset test suite");
+ throw "Please disable your popup blocker for the offset test suite";
+ }
+ return win;
+ }
+};
+
+testwin("absolute", function() {
+ var $w = testwin["absolute"].$;
+
+ equals( $w('#absolute-1').offset().top, 1, "$('#absolute-1').offset().top" );
+ equals( $w('#absolute-1').offset().left, 1, "$('#absolute-1').offset().left" );
+
+ equals( $w('#absolute-1-1').offset().top, 5, "$('#absolute-1-1').offset().top" );
+ equals( $w('#absolute-1-1').offset().left, 5, "$('#absolute-1-1').offset().left" );
+
+ equals( $w('#absolute-1-1-1').offset().top, 9, "$('#absolute-1-1-1').offset().top" );
+ equals( $w('#absolute-1-1-1').offset().left, 9, "$('#absolute-1-1-1').offset().left" );
+
+ equals( $w('#absolute-2').offset().top, 20, "$('#absolute-2').offset().top" );
+ equals( $w('#absolute-2').offset().left, 20, "$('#absolute-2').offset().left" );
+
+
+ equals( $w('#absolute-1').position().top, 0, "$('#absolute-1').position().top" );
+ equals( $w('#absolute-1').position().left, 0, "$('#absolute-1').position().left" );
+
+ equals( $w('#absolute-1-1').position().top, 1, "$('#absolute-1-1').position().top" );
+ equals( $w('#absolute-1-1').position().left, 1, "$('#absolute-1-1').position().left" );
+
+ equals( $w('#absolute-1-1-1').position().top, 1, "$('#absolute-1-1-1').position().top" );
+ equals( $w('#absolute-1-1-1').position().left, 1, "$('#absolute-1-1-1').position().left" );
+
+ equals( $w('#absolute-2').position().top, 19, "$('#absolute-2').position().top" );
+ equals( $w('#absolute-2').position().left, 19, "$('#absolute-2').position().left" );
+
+ testwin["absolute"].close();
+});
+
+testwin("relative", function() {
+ var $w = testwin["relative"].$;
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#relative-1').offset().top, $.browser.msie ? 6 : 7, "$('#relative-1').offset().top" );
+ equals( $w('#relative-1').offset().left, 7, "$('#relative-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#relative-1-1').offset().top, $.browser.msie ? 13 : 15, "$('#relative-1-1').offset().top" );
+ equals( $w('#relative-1-1').offset().left, 15, "$('#relative-1-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#relative-2').offset().top, $.browser.msie ? 141 : 142, "$('#relative-2').offset().top" );
+ equals( $w('#relative-2').offset().left, 27, "$('#relative-2').offset().left" );
+
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#relative-1').position().top, $.browser.msie ? 5 : 6, "$('#relative-1').position().top" );
+ equals( $w('#relative-1').position().left, 6, "$('#relative-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#relative-1-1').position().top, $.browser.msie ? 4 : 5, "$('#relative-1-1').position().top" );
+ equals( $w('#relative-1-1').position().left, 5, "$('#relative-1-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#relative-2').position().top, $.browser.msie ? 140 : 141, "$('#relative-2').position().top" );
+ equals( $w('#relative-2').position().left, 26, "$('#relative-2').position().left" );
+
+ testwin["relative"].close();
+});
+
+testwin("static", function() {
+ var $w = testwin["static"].$;
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-1').offset().top, $.browser.msie ? 6 : 7, "$('#static-1').offset().top" );
+ equals( $w('#static-1').offset().left, 7, "$('#static-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-1-1').offset().top, $.browser.msie ? 13 : 15, "$('#static-1-1').offset().top" );
+ equals( $w('#static-1-1').offset().left, 15, "$('#static-1-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-1-1-1').offset().top, $.browser.msie ? 20 : 23, "$('#static-1-1-1').offset().top" );
+ equals( $w('#static-1-1-1').offset().left, 23, "$('#static-1-1-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-2').offset().top, $.browser.msie ? 121 : 122, "$('#static-2').offset().top" );
+ equals( $w('#static-2').offset().left, 7, "$('#static-2').offset().left" );
+
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-1').position().top, $.browser.msie ? 5 : 6, "$('#static-1').position().top" );
+ equals( $w('#static-1').position().left, 6, "$('#static-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-1-1').position().top, $.browser.msie ? 12 : 14, "$('#static-1-1').position().top" );
+ equals( $w('#static-1-1').position().left, 14, "$('#static-1-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-1-1-1').position().top, $.browser.msie ? 19 : 22, "$('#static-1-1-1').position().top" );
+ equals( $w('#static-1-1-1').position().left, 22, "$('#static-1-1-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#static-2').position().top, $.browser.msie ? 120 : 121, "$('#static-2').position().top" );
+ equals( $w('#static-2').position().left, 6, "$('#static-2').position().left" );
+
+ testwin["static"].close();
+});
+
+if ( !$.browser.msie || ($.browser.msie && parseInt($.browser.version) > 6) )
+ testwin("fixed", function() {
+ var $w = testwin["fixed"].$;
+
+ equals( $w('#fixed-1').offset().top, 1001, "$('#fixed-1').offset().top" );
+ equals( $w('#fixed-1').offset().left, $.browser.msie ? 994 : 1001, "$('#fixed-1').offset().left" );
+
+ equals( $w('#fixed-2').offset().top, 1021, "$('#fixed-2').offset().top" );
+ equals( $w('#fixed-2').offset().left, $.browser.msie ? 1014 : 1021, "$('#fixed-2').offset().left" );
+
+ testwin["fixed"].close();
+ });
+
+testwin("table", function() {
+ var $w = testwin["table"].$;
+
+ equals( $w('#table-1').offset().top, 6, "$('#table-1').offset().top" );
+ equals( $w('#table-1').offset().left, 6, "$('#table-1').offset().left" );
+
+ equals( $w('#th-1').offset().top, 10, "$('#table-1').offset().top" );
+ equals( $w('#th-1').offset().left, 10, "$('#table-1').offset().left" );
+
+ equals( $w('#th-2').offset().top, 10, "$('#table-1').offset().top" );
+ equals( $w('#th-2').offset().left, 116, "$('#table-1').offset().left" );
+
+ testwin["table"].close();
+});
+
+testwin("scroll", function() {
+ var $w = testwin["scroll"].$;
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#scroll-1').offset().top, $.browser.msie ? 6 : 7, "$('#scroll-1').offset().top" );
+ equals( $w('#scroll-1').offset().left, 7, "$('#scroll-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( $w('#scroll-1-1').offset().top, $.browser.msie ? 9 : 11, "$('#scroll-1-1').offset().top" );
+ equals( $w('#scroll-1-1').offset().left, 11, "$('#scroll-1-1').offset().left" );
+
+ testwin["scroll"].close();
+}); \ No newline at end of file
diff --git a/dom/tests/mochitest/ajax/jquery/test/unit/selector.js b/dom/tests/mochitest/ajax/jquery/test/unit/selector.js
new file mode 100644
index 0000000000..07c4434d09
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/unit/selector.js
@@ -0,0 +1,224 @@
+module("selector");
+
+test("element", function() {
+ expect(9);
+ ok( $("*").size() >= 30, "Select all" );
+ var all = $("*"), good = true;
+ for ( var i = 0; i < all.length; i++ )
+ if ( all[i].nodeType == 8 )
+ good = false;
+ ok( good, "Select all elements, no comment nodes" );
+ t( "Element Selector", "p", ["firstp","ap","sndp","en","sap","first"] );
+ t( "Element Selector", "body", ["body"] );
+ t( "Element Selector", "html", ["html"] );
+ t( "Parent Element", "div p", ["firstp","ap","sndp","en","sap","first"] );
+ equals( $("param", "#object1").length, 2, "Object/param as context" );
+
+ ok( $("#length").length, '&lt;input name="length"&gt; cannot be found under IE, see #945' );
+ ok( $("#lengthtest input").length, '&lt;input name="length"&gt; cannot be found under IE, see #945' );
+});
+
+if ( location.protocol != "file:" ) {
+ test("Element Selector with underscore", function() {
+ expect(1);
+ stop();
+ $.get("data/with_fries.xml", function(xml) {
+ equals( $("foo_bar", xml).length, 1, "Element Selector with underscore" );
+ start();
+ });
+ });
+}
+
+test("broken", function() {
+ expect(7);
+ t( "Broken Selector", "[", [] );
+ t( "Broken Selector", "(", [] );
+ t( "Broken Selector", "{", [] );
+ t( "Broken Selector", "<", [] );
+ t( "Broken Selector", "()", [] );
+ t( "Broken Selector", "<>", [] );
+ t( "Broken Selector", "{}", [] );
+});
+
+test("id", function() {
+ expect(25);
+ t( "ID Selector", "#body", ["body"] );
+ t( "ID Selector w/ Element", "body#body", ["body"] );
+ t( "ID Selector w/ Element", "ul#first", [] );
+ t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );
+ t( "ID selector with non-existant descendant", "#firstp #foobar", [] );
+ t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] );
+ t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] );
+ t( "Descendant ID selector using UTF8", "div #台北", ["台北"] );
+ t( "Child ID selector using UTF8", "form > #台北", ["台北"] );
+
+ t( "Escaped ID", "#foo\\:bar", ["foo:bar"] );
+ t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
+ t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] );
+ t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
+ t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] );
+ t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
+
+ t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267
+ t( "ID Selector, not an ancestor ID", "#form #first", [] );
+ t( "ID Selector, not a child ID", "#form > #option1a", [] );
+
+ t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
+ t( "All Children of ID with no children", "#firstUL/*", [] );
+
+ $('<a name="tName1">tName1 A</a><a name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');
+ equals( $("#tName1")[0].id, 'tName1', "ID selector with same value for a name attribute" );
+ equals( $("#tName2").length, 0, "ID selector non-existing but name attribute on an A tag" );
+ t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"] );
+
+ t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986
+
+ isSet( $("body").find("div#form"), [], "ID selector within the context of another element" );
+});
+
+test("class", function() {
+ expect(16);
+ t( "Class Selector", ".blog", ["mark","simon"] );
+ t( "Class Selector", ".blog.link", ["simon"] );
+ t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
+ t( "Parent Class Selector", "p .blog", ["mark","simon"] );
+
+ t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] );
+ t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
+ t( "Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"] );
+ t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] );
+ t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] );
+ t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] );
+
+ t( "Escaped Class", ".foo\\:bar", ["foo:bar"] );
+ t( "Escaped Class", ".test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
+ t( "Descendant scaped Class", "div .foo\\:bar", ["foo:bar"] );
+ t( "Descendant scaped Class", "div .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
+ t( "Child escaped Class", "form > .foo\\:bar", ["foo:bar"] );
+ t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
+});
+
+test("multiple", function() {
+ expect(4);
+ t( "Comma Support", "a.blog, p", ["mark","simon","firstp","ap","sndp","en","sap","first"] );
+ t( "Comma Support", "a.blog , p", ["mark","simon","firstp","ap","sndp","en","sap","first"] );
+ t( "Comma Support", "a.blog ,p", ["mark","simon","firstp","ap","sndp","en","sap","first"] );
+ t( "Comma Support", "a.blog,p", ["mark","simon","firstp","ap","sndp","en","sap","first"] );
+});
+
+test("child and adjacent", function() {
+ expect(37);
+ t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
+ t( "All Children", "code > *", ["anchor1","anchor2"] );
+ t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
+ t( "Adjacent", "a + a", ["groups"] );
+ t( "Adjacent", "a +a", ["groups"] );
+ t( "Adjacent", "a+ a", ["groups"] );
+ t( "Adjacent", "a+a", ["groups"] );
+ t( "Adjacent", "p + p", ["ap","en","sap"] );
+ t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
+
+ t( "First Child", "p:first-child", ["firstp","sndp"] );
+ t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
+
+ t( "Last Child", "p:last-child", ["sap"] );
+ t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon"] );
+
+ t( "Nth-child", "#main form#form > *:nth-child(2)", ["text2"] );
+ t( "Nth-child", "#main form#form > :nth-child(2)", ["text2"] );
+
+ t( "Nth-child", "#form select:first option:nth-child(3)", ["option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(0n+3)", ["option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(even)", ["option1b", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(odd)", ["option1a", "option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(2n)", ["option1b", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(2n+1)", ["option1a", "option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n)", ["option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n+1)", ["option1a", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n+2)", ["option1b"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n+3)", ["option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n-1)", ["option1b"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n-2)", ["option1a", "option1d"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n-3)", ["option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(3n+0)", ["option1c"] );
+ t( "Nth-child", "#form select:first option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] );
+});
+
+test("attributes", function() {
+ expect(20);
+ t( "Attribute Exists", "a[title]", ["google"] );
+ t( "Attribute Exists", "*[title]", ["google"] );
+ t( "Attribute Exists", "[title]", ["google"] );
+
+ t( "Attribute Equals", "a[rel='bookmark']", ["simon1"] );
+ t( "Attribute Equals", 'a[rel="bookmark"]', ["simon1"] );
+ t( "Attribute Equals", "a[rel=bookmark]", ["simon1"] );
+ t( "Multiple Attribute Equals", "#form input[type='hidden'],#form input[type='radio']", ["hidden1","radio1","radio2"] );
+ t( "Multiple Attribute Equals", "#form input[type=\"hidden\"],#form input[type='radio']", ["hidden1","radio1","radio2"] );
+ t( "Multiple Attribute Equals", "#form input[type=hidden],#form input[type=radio]", ["hidden1","radio1","radio2"] );
+
+ t( "Attribute selector using UTF8", "span[lang=中文]", ["台北"] );
+
+ t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] );
+ t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
+ t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
+
+ t("Select options via [selected]", "#select1 option[selected]", ["option1a"] );
+ t("Select options via [selected]", "#select2 option[selected]", ["option2d"] );
+ t("Select options via [selected]", "#select3 option[selected]", ["option3b", "option3c"] );
+
+ t( "Grouped Form Elements", "input[name='foo[bar]']", ["hidden2"] );
+
+ t( ":not() Existing attribute", "#form select:not([multiple])", ["select1", "select2"]);
+ t( ":not() Equals attribute", "#form select:not([name=select1])", ["select2", "select3"]);
+ t( ":not() Equals quoted attribute", "#form select:not([name='select1'])", ["select2", "select3"]);
+});
+
+test("pseudo (:) selectors", function() {
+ expect(35);
+ t( "First Child", "p:first-child", ["firstp","sndp"] );
+ t( "Last Child", "p:last-child", ["sap"] );
+ t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
+ t( "Empty", "ul:empty", ["firstUL"] );
+ t( "Enabled UI Element", "#form input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
+ t( "Disabled UI Element", "#form input:disabled", ["text2"] );
+ t( "Checked UI Element", "#form input:checked", ["radio2","check1"] );
+ t( "Selected Option Element", "#form option:selected", ["option1a","option2d","option3b","option3c"] );
+ t( "Text Contains", "a:contains('Google')", ["google","groups"] );
+ t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
+ t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests", "moretests"] );
+ t( "Not", "a.blog:not(.link)", ["mark"] );
+ t( "Not - multiple", "#form option:not(:contains('Nothing'),#option1b,:selected)", ["option1c", "option1d", "option2b", "option2c", "option3d"] );
+ t( "Not - complex", "#form option:not([id^='opt']:gt(0):nth-child(-n+3))", [ "option1a", "option1d", "option2d", "option3d"] );
+ t( "Not - recursive", "#form option:not(:not(:selected))[id^='option3']", [ "option3b", "option3c"] );
+
+ t( "nth Element", "p:nth(1)", ["ap"] );
+ t( "First Element", "p:first", ["firstp"] );
+ t( "Last Element", "p:last", ["first"] );
+ t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
+ t( "Odd Elements", "p:odd", ["ap","en","first"] );
+ t( "Position Equals", "p:eq(1)", ["ap"] );
+ t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
+ t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
+ t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
+ t( "Is Visible", "#form input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
+ t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
+
+ t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
+ t( "Form element :radio", "#form :radio", ["radio1", "radio2"] );
+ t( "Form element :checkbox", "#form :checkbox", ["check1", "check2"] );
+ t( "Form element :text", "#form :text", ["text1", "text2", "hidden2", "name"] );
+ t( "Form element :radio:checked", "#form :radio:checked", ["radio2"] );
+ t( "Form element :checkbox:checked", "#form :checkbox:checked", ["check1"] );
+ t( "Form element :checkbox:checked, :radio:checked", "#form :checkbox:checked, #form :radio:checked", ["check1", "radio2"] );
+
+ t( "Headers", ":header", ["header", "banner", "userAgent"] );
+ t( "Has Children - :has()", "p:has(a)", ["firstp","ap","en","sap"] );
+});
diff --git a/dom/tests/mochitest/ajax/jquery/test_jQuery.html b/dom/tests/mochitest/ajax/jquery/test_jQuery.html
new file mode 100644
index 0000000000..1a02d3523c
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test_jQuery.html
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for jQuery</title>
+ <script src="/MochiKit/Base.js"></script>
+ <script src="/MochiKit/Async.js"></script>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript">
+ // On Linux 64 Stylo Disabled, we observed a failure in the
+ // test 'stop() - several in queue' in fx.js with a low precision value.
+ // We specify a value that seems safe. The root cause of this issue is
+ // believed to be jQuery's use of new Date as a mechanism to advance animations.
+ SpecialPowers.pushPrefEnv({set:
+ [["privacy.reduceTimerPrecision", true],
+ ["privacy.resistFingerprinting.reduceTimerPrecision.microseconds", 2000]]});
+ </script>
+ <script type="text/javascript" src="../lib/AJAX_setup.js"></script>
+ <link rel="stylesheet" type="text/css" href="../lib/test.css" />
+</head>
+<body>
+ <iframe width="100%" height="500" id="testframe" src=""></iframe>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/ajax/jquery/version.txt b/dom/tests/mochitest/ajax/jquery/version.txt
new file mode 100644
index 0000000000..3c43790f5d
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/version.txt
@@ -0,0 +1 @@
+1.2.6