lady_josephine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/app/assets/fonts/lady_josephine/icons/icons.eot +0 -0
- data/app/assets/fonts/lady_josephine/icons/icons.svg +215 -0
- data/app/assets/fonts/lady_josephine/icons/icons.ttf +0 -0
- data/app/assets/fonts/lady_josephine/icons/icons.woff +0 -0
- data/app/assets/javascripts/lady_josephine/blocks/facebook.js +25 -0
- data/app/assets/javascripts/lady_josephine/blocks/instagram.js +22 -0
- data/app/assets/javascripts/lady_josephine/blocks/soundcloud.js +24 -0
- data/app/assets/javascripts/lady_josephine/blocks/twitter.js +25 -0
- data/app/assets/javascripts/lady_josephine/blocks/vimeo.js +55 -0
- data/app/assets/javascripts/lady_josephine/blocks/youtube.js +64 -0
- data/app/assets/javascripts/lady_josephine/editor.js +40 -0
- data/app/assets/javascripts/lady_josephine/lady_josephine.js +4 -0
- data/app/assets/javascripts/lady_josephine/lady_josephine_view.js +6 -0
- data/app/assets/stylesheets/lady_josephine/content.sass +33 -0
- data/app/assets/stylesheets/lady_josephine/icons.sass +175 -0
- data/app/assets/stylesheets/lady_josephine/lady_josephine.sass +6 -0
- data/app/assets/stylesheets/lady_josephine/sir_trevor.sass +619 -0
- data/app/assets/stylesheets/lady_josephine/vars.sass +36 -0
- data/app/controllers/lady_josephine/application_controller.rb +4 -0
- data/app/controllers/lady_josephine/editor_controller.rb +40 -0
- data/app/controllers/lady_josephine/images_controller.rb +26 -0
- data/app/helpers/lady_josephine/helper.rb +25 -0
- data/app/helpers/lady_josephine/sir_trevor_helper.rb +172 -0
- data/app/models/lady_josephine/concerns/model.rb +29 -0
- data/app/models/lady_josephine/concerns/pingable.rb +28 -0
- data/app/models/lady_josephine/concerns/server_uuid.rb +24 -0
- data/app/models/lady_josephine/concerns/sir_trevor_images.rb +38 -0
- data/app/models/lady_josephine/image.rb +41 -0
- data/app/uploader/lady_josephine/base_uploader.rb +47 -0
- data/app/uploader/lady_josephine/image_uploader.rb +149 -0
- data/app/views/lady_josephine/blocks/_audio_block.haml +2 -0
- data/app/views/lady_josephine/blocks/_definition_block.haml +4 -0
- data/app/views/lady_josephine/blocks/_divider_block.haml +2 -0
- data/app/views/lady_josephine/blocks/_extended_image_block.haml +63 -0
- data/app/views/lady_josephine/blocks/_extended_quote_block.haml +5 -0
- data/app/views/lady_josephine/blocks/_extended_tweet_block.haml +2 -0
- data/app/views/lady_josephine/blocks/_facebook_post_block.haml +2 -0
- data/app/views/lady_josephine/blocks/_heading_block.haml +2 -0
- data/app/views/lady_josephine/blocks/_html_block.haml +1 -0
- data/app/views/lady_josephine/blocks/_instagram_block.haml +2 -0
- data/app/views/lady_josephine/blocks/_list_block.haml +3 -0
- data/app/views/lady_josephine/blocks/_quote_block.haml +5 -0
- data/app/views/lady_josephine/blocks/_text_block.html.haml +2 -0
- data/app/views/lady_josephine/blocks/_video_block.haml +9 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20160222151500_lady_josephine_image.rb +18 -0
- data/lib/generators/lady_josephine_migration/USAGE +9 -0
- data/lib/generators/lady_josephine_migration/lady_josephine_migration_generator.rb +17 -0
- data/lib/generators/lady_josephine_migration/templates/migration.rb +9 -0
- data/lib/lady_josephine.rb +18 -0
- data/lib/lady_josephine/engine.rb +18 -0
- data/lib/lady_josephine/redcarpet/custom_markdown_formatter.rb +63 -0
- data/lib/lady_josephine/renderer/sir_trevor_renderer.rb +16 -0
- data/lib/lady_josephine/version.rb +3 -0
- data/lib/lady_josephine/whitelist.rb +26 -0
- data/lib/tasks/lady_josephine_tasks.rake +4 -0
- data/spec/controllers/lady_josephine/editor_controller_spec.rb +58 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/bla +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +17 -0
- data/vendor/assets/components/Eventable/README.md +12 -0
- data/vendor/assets/components/Eventable/bower.json +10 -0
- data/vendor/assets/components/Eventable/component.json +11 -0
- data/vendor/assets/components/Eventable/eventable.js +207 -0
- data/vendor/assets/components/Eventable/package.json +15 -0
- data/vendor/assets/components/jquery-autosize/bower.json +30 -0
- data/vendor/assets/components/jquery-autosize/demo.html +36 -0
- data/vendor/assets/components/jquery-autosize/jquery.autosize.js +273 -0
- data/vendor/assets/components/jquery-autosize/jquery.autosize.min.js +6 -0
- data/vendor/assets/components/jquery-autosize/package.json +32 -0
- data/vendor/assets/components/jquery-autosize/readme.md +216 -0
- data/vendor/assets/components/jquery/AUTHORS.txt +163 -0
- data/vendor/assets/components/jquery/CONTRIBUTING.md +216 -0
- data/vendor/assets/components/jquery/Gruntfile.js +496 -0
- data/vendor/assets/components/jquery/MIT-LICENSE.txt +21 -0
- data/vendor/assets/components/jquery/README.md +415 -0
- data/vendor/assets/components/jquery/build/release-notes.js +59 -0
- data/vendor/assets/components/jquery/build/release.js +246 -0
- data/vendor/assets/components/jquery/component.json +13 -0
- data/vendor/assets/components/jquery/composer.json +35 -0
- data/vendor/assets/components/jquery/jquery-migrate.js +496 -0
- data/vendor/assets/components/jquery/jquery-migrate.min.js +3 -0
- data/vendor/assets/components/jquery/jquery.js +9597 -0
- data/vendor/assets/components/jquery/jquery.min.js +5 -0
- data/vendor/assets/components/jquery/jquery.min.map +1 -0
- data/vendor/assets/components/jquery/package.json +39 -0
- data/vendor/assets/components/jquery/speed/benchmark.js +15 -0
- data/vendor/assets/components/jquery/speed/benchmarker.css +65 -0
- data/vendor/assets/components/jquery/speed/benchmarker.js +181 -0
- data/vendor/assets/components/jquery/speed/closest.html +39 -0
- data/vendor/assets/components/jquery/speed/css.html +82 -0
- data/vendor/assets/components/jquery/speed/event.html +58 -0
- data/vendor/assets/components/jquery/speed/filter.html +183 -0
- data/vendor/assets/components/jquery/speed/find.html +179 -0
- data/vendor/assets/components/jquery/speed/index.html +72 -0
- data/vendor/assets/components/jquery/speed/jquery-basis.js +6238 -0
- data/vendor/assets/components/jquery/speed/slice.vs.concat.html +47 -0
- data/vendor/assets/components/jquery/src/ajax.js +851 -0
- data/vendor/assets/components/jquery/src/ajax/jsonp.js +80 -0
- data/vendor/assets/components/jquery/src/ajax/script.js +86 -0
- data/vendor/assets/components/jquery/src/ajax/xhr.js +207 -0
- data/vendor/assets/components/jquery/src/attributes.js +661 -0
- data/vendor/assets/components/jquery/src/callbacks.js +196 -0
- data/vendor/assets/components/jquery/src/core.js +949 -0
- data/vendor/assets/components/jquery/src/css.js +679 -0
- data/vendor/assets/components/jquery/src/data.js +340 -0
- data/vendor/assets/components/jquery/src/deferred.js +141 -0
- data/vendor/assets/components/jquery/src/deprecated.js +4 -0
- data/vendor/assets/components/jquery/src/dimensions.js +41 -0
- data/vendor/assets/components/jquery/src/effects.js +730 -0
- data/vendor/assets/components/jquery/src/event-alias.js +15 -0
- data/vendor/assets/components/jquery/src/event.js +991 -0
- data/vendor/assets/components/jquery/src/exports.js +18 -0
- data/vendor/assets/components/jquery/src/intro.js +20 -0
- data/vendor/assets/components/jquery/src/manipulation.js +796 -0
- data/vendor/assets/components/jquery/src/offset.js +169 -0
- data/vendor/assets/components/jquery/src/outro.js +2 -0
- data/vendor/assets/components/jquery/src/queue.js +147 -0
- data/vendor/assets/components/jquery/src/serialize.js +99 -0
- data/vendor/assets/components/jquery/src/sizzle-jquery.js +9 -0
- data/vendor/assets/components/jquery/src/support.js +241 -0
- data/vendor/assets/components/jquery/src/traversing.js +275 -0
- data/vendor/assets/components/jquery/test/csp.php +16 -0
- data/vendor/assets/components/jquery/test/data/1x1.jpg +0 -0
- data/vendor/assets/components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
- data/vendor/assets/components/jquery/test/data/atom+xml.php +4 -0
- data/vendor/assets/components/jquery/test/data/badcall.js +1 -0
- data/vendor/assets/components/jquery/test/data/badjson.js +1 -0
- data/vendor/assets/components/jquery/test/data/cleanScript.html +10 -0
- data/vendor/assets/components/jquery/test/data/core/cc_on.html +22 -0
- data/vendor/assets/components/jquery/test/data/dashboard.xml +11 -0
- data/vendor/assets/components/jquery/test/data/dimensions/documentLarge.html +17 -0
- data/vendor/assets/components/jquery/test/data/dimensions/documentSmall.html +21 -0
- data/vendor/assets/components/jquery/test/data/echoData.php +1 -0
- data/vendor/assets/components/jquery/test/data/echoQuery.php +1 -0
- data/vendor/assets/components/jquery/test/data/errorWithText.php +5 -0
- data/vendor/assets/components/jquery/test/data/etag.php +21 -0
- data/vendor/assets/components/jquery/test/data/evalScript.php +1 -0
- data/vendor/assets/components/jquery/test/data/event/longLoadScript.php +4 -0
- data/vendor/assets/components/jquery/test/data/event/promiseReady.html +17 -0
- data/vendor/assets/components/jquery/test/data/event/syncReady.html +23 -0
- data/vendor/assets/components/jquery/test/data/headers.php +18 -0
- data/vendor/assets/components/jquery/test/data/if_modified_since.php +20 -0
- data/vendor/assets/components/jquery/test/data/iframe.html +8 -0
- data/vendor/assets/components/jquery/test/data/jquery-1.8.2.ajax_xhr.min.js +2 -0
- data/vendor/assets/components/jquery/test/data/json.php +13 -0
- data/vendor/assets/components/jquery/test/data/json_obj.js +1 -0
- data/vendor/assets/components/jquery/test/data/jsonp.php +14 -0
- data/vendor/assets/components/jquery/test/data/manipulation/iframe-denied.html +36 -0
- data/vendor/assets/components/jquery/test/data/name.html +1 -0
- data/vendor/assets/components/jquery/test/data/name.php +24 -0
- data/vendor/assets/components/jquery/test/data/nocontent.php +5 -0
- data/vendor/assets/components/jquery/test/data/offset/absolute.html +41 -0
- data/vendor/assets/components/jquery/test/data/offset/body.html +26 -0
- data/vendor/assets/components/jquery/test/data/offset/fixed.html +34 -0
- data/vendor/assets/components/jquery/test/data/offset/relative.html +31 -0
- data/vendor/assets/components/jquery/test/data/offset/scroll.html +39 -0
- data/vendor/assets/components/jquery/test/data/offset/static.html +31 -0
- data/vendor/assets/components/jquery/test/data/offset/table.html +43 -0
- data/vendor/assets/components/jquery/test/data/params_html.php +12 -0
- data/vendor/assets/components/jquery/test/data/readywaitasset.js +1 -0
- data/vendor/assets/components/jquery/test/data/readywaitloader.js +25 -0
- data/vendor/assets/components/jquery/test/data/script.php +11 -0
- data/vendor/assets/components/jquery/test/data/selector/html5_selector.html +114 -0
- data/vendor/assets/components/jquery/test/data/selector/sizzle_cache.html +21 -0
- data/vendor/assets/components/jquery/test/data/statusText.php +5 -0
- data/vendor/assets/components/jquery/test/data/support/bodyBackground.html +28 -0
- data/vendor/assets/components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
- data/vendor/assets/components/jquery/test/data/support/testElementCrash.html +17 -0
- data/vendor/assets/components/jquery/test/data/test.html +7 -0
- data/vendor/assets/components/jquery/test/data/test.js +3 -0
- data/vendor/assets/components/jquery/test/data/test.php +7 -0
- data/vendor/assets/components/jquery/test/data/test2.html +5 -0
- data/vendor/assets/components/jquery/test/data/test3.html +3 -0
- data/vendor/assets/components/jquery/test/data/testinit.js +269 -0
- data/vendor/assets/components/jquery/test/data/testrunner.js +368 -0
- data/vendor/assets/components/jquery/test/data/testsuite.css +155 -0
- data/vendor/assets/components/jquery/test/data/text.php +12 -0
- data/vendor/assets/components/jquery/test/data/ua.txt +272 -0
- data/vendor/assets/components/jquery/test/data/with_fries.xml +25 -0
- data/vendor/assets/components/jquery/test/data/with_fries_over_jsonp.php +7 -0
- data/vendor/assets/components/jquery/test/delegatetest.html +228 -0
- data/vendor/assets/components/jquery/test/hovertest.html +158 -0
- data/vendor/assets/components/jquery/test/index.html +330 -0
- data/vendor/assets/components/jquery/test/localfile.html +75 -0
- data/vendor/assets/components/jquery/test/networkerror.html +84 -0
- data/vendor/assets/components/jquery/test/polluted.php +110 -0
- data/vendor/assets/components/jquery/test/readywait.html +70 -0
- data/vendor/assets/components/jquery/test/unit/ajax.js +1971 -0
- data/vendor/assets/components/jquery/test/unit/attributes.js +1332 -0
- data/vendor/assets/components/jquery/test/unit/callbacks.js +326 -0
- data/vendor/assets/components/jquery/test/unit/core.js +1332 -0
- data/vendor/assets/components/jquery/test/unit/css.js +1036 -0
- data/vendor/assets/components/jquery/test/unit/data.js +636 -0
- data/vendor/assets/components/jquery/test/unit/deferred.js +440 -0
- data/vendor/assets/components/jquery/test/unit/deprecated.js +1 -0
- data/vendor/assets/components/jquery/test/unit/dimensions.js +461 -0
- data/vendor/assets/components/jquery/test/unit/effects.js +2050 -0
- data/vendor/assets/components/jquery/test/unit/event.js +2690 -0
- data/vendor/assets/components/jquery/test/unit/exports.js +7 -0
- data/vendor/assets/components/jquery/test/unit/manipulation.js +2242 -0
- data/vendor/assets/components/jquery/test/unit/offset.js +549 -0
- data/vendor/assets/components/jquery/test/unit/queue.js +316 -0
- data/vendor/assets/components/jquery/test/unit/selector.js +185 -0
- data/vendor/assets/components/jquery/test/unit/serialize.js +146 -0
- data/vendor/assets/components/jquery/test/unit/support.js +384 -0
- data/vendor/assets/components/jquery/test/unit/traversing.js +667 -0
- data/vendor/assets/components/jquery/test/xhtml.php +5 -0
- data/vendor/assets/components/sir-trevor-js/CHANGELOG.md +44 -0
- data/vendor/assets/components/sir-trevor-js/Gemfile +3 -0
- data/vendor/assets/components/sir-trevor-js/Gemfile.lock +10 -0
- data/vendor/assets/components/sir-trevor-js/Gruntfile.js +109 -0
- data/vendor/assets/components/sir-trevor-js/MIT-LICENCE +20 -0
- data/vendor/assets/components/sir-trevor-js/Readme.md +84 -0
- data/vendor/assets/components/sir-trevor-js/bower.json +21 -0
- data/vendor/assets/components/sir-trevor-js/component.json +42 -0
- data/vendor/assets/components/sir-trevor-js/contributing.md +74 -0
- data/vendor/assets/components/sir-trevor-js/examples-component/component.json +14 -0
- data/vendor/assets/components/sir-trevor-js/examples-component/index.html +33 -0
- data/vendor/assets/components/sir-trevor-js/examples-component/index.js +29 -0
- data/vendor/assets/components/sir-trevor-js/examples-component/javascript/example_block.js +203 -0
- data/vendor/assets/components/sir-trevor-js/examples-component/javascript/limit_chars.js +46 -0
- data/vendor/assets/components/sir-trevor-js/examples-component/sir-trevor.gif +0 -0
- data/vendor/assets/components/sir-trevor-js/locales/cn.js +51 -0
- data/vendor/assets/components/sir-trevor-js/locales/de.js +51 -0
- data/vendor/assets/components/sir-trevor-js/locales/es.js +51 -0
- data/vendor/assets/components/sir-trevor-js/locales/fi.js +51 -0
- data/vendor/assets/components/sir-trevor-js/locales/fr.js +51 -0
- data/vendor/assets/components/sir-trevor-js/locales/pt.js +52 -0
- data/vendor/assets/components/sir-trevor-js/package.json +23 -0
- data/vendor/assets/components/sir-trevor-js/sir-trevor-icons.css +6 -0
- data/vendor/assets/components/sir-trevor-js/sir-trevor.css +393 -0
- data/vendor/assets/components/sir-trevor-js/sir-trevor.css.map +7 -0
- data/vendor/assets/components/sir-trevor-js/sir-trevor.js +5481 -0
- data/vendor/assets/components/sir-trevor-js/sir-trevor.min.js +13 -0
- data/vendor/assets/components/underscore/CNAME +1 -0
- data/vendor/assets/components/underscore/CONTRIBUTING.md +9 -0
- data/vendor/assets/components/underscore/LICENSE +22 -0
- data/vendor/assets/components/underscore/README.md +19 -0
- data/vendor/assets/components/underscore/Rakefile +10 -0
- data/vendor/assets/components/underscore/docs/docco.css +192 -0
- data/vendor/assets/components/underscore/docs/favicon.ico +0 -0
- data/vendor/assets/components/underscore/docs/images/background.png +0 -0
- data/vendor/assets/components/underscore/docs/images/underscore.png +0 -0
- data/vendor/assets/components/underscore/docs/underscore.html +823 -0
- data/vendor/assets/components/underscore/favicon.ico +0 -0
- data/vendor/assets/components/underscore/index.html +2467 -0
- data/vendor/assets/components/underscore/index.js +1 -0
- data/vendor/assets/components/underscore/package.json +16 -0
- data/vendor/assets/components/underscore/test/arrays.js +200 -0
- data/vendor/assets/components/underscore/test/chaining.js +59 -0
- data/vendor/assets/components/underscore/test/collections.js +453 -0
- data/vendor/assets/components/underscore/test/functions.js +265 -0
- data/vendor/assets/components/underscore/test/index.html +44 -0
- data/vendor/assets/components/underscore/test/objects.js +570 -0
- data/vendor/assets/components/underscore/test/speed.js +75 -0
- data/vendor/assets/components/underscore/test/utility.js +266 -0
- data/vendor/assets/components/underscore/test/vendor/jquery.js +9404 -0
- data/vendor/assets/components/underscore/test/vendor/jslitmus.js +670 -0
- data/vendor/assets/components/underscore/test/vendor/qunit.css +235 -0
- data/vendor/assets/components/underscore/test/vendor/qunit.js +1977 -0
- data/vendor/assets/components/underscore/test/vendor/runner.js +98 -0
- data/vendor/assets/components/underscore/underscore-min.js +1 -0
- data/vendor/assets/components/underscore/underscore.js +1226 -0
- metadata +473 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
module( "callbacks", {
|
|
2
|
+
teardown: moduleTeardown
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
(function() {
|
|
6
|
+
|
|
7
|
+
var output,
|
|
8
|
+
addToOutput = function( string ) {
|
|
9
|
+
return function() {
|
|
10
|
+
output += string;
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
outputA = addToOutput("A"),
|
|
14
|
+
outputB = addToOutput("B"),
|
|
15
|
+
outputC = addToOutput("C"),
|
|
16
|
+
tests = {
|
|
17
|
+
"": "XABC X XABCABCC X XBB X XABA X XX",
|
|
18
|
+
"once": "XABC X X X X X XABA X XX",
|
|
19
|
+
"memory": "XABC XABC XABCABCCC XA XBB XB XABA XC XX",
|
|
20
|
+
"unique": "XABC X XABCA X XBB X XAB X X",
|
|
21
|
+
"stopOnFalse": "XABC X XABCABCC X XBB X XA X XX",
|
|
22
|
+
"once memory": "XABC XABC X XA X XA XABA XC XX",
|
|
23
|
+
"once unique": "XABC X X X X X XAB X X",
|
|
24
|
+
"once stopOnFalse": "XABC X X X X X XA X XX",
|
|
25
|
+
"memory unique": "XABC XA XABCA XA XBB XB XAB XC X",
|
|
26
|
+
"memory stopOnFalse": "XABC XABC XABCABCCC XA XBB XB XA X XX",
|
|
27
|
+
"unique stopOnFalse": "XABC X XABCA X XBB X XA X X"
|
|
28
|
+
},
|
|
29
|
+
filters = {
|
|
30
|
+
"no filter": undefined,
|
|
31
|
+
"filter": function( fn ) {
|
|
32
|
+
return function() {
|
|
33
|
+
return fn.apply( this, arguments );
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function showFlags( flags ) {
|
|
39
|
+
if ( typeof flags === "string" ) {
|
|
40
|
+
return "'" + flags + "'";
|
|
41
|
+
}
|
|
42
|
+
var output = [], key;
|
|
43
|
+
for ( key in flags ) {
|
|
44
|
+
output.push( "'" + key + "': " + flags[ key ] );
|
|
45
|
+
}
|
|
46
|
+
return "{ " + output.join( ", " ) + " }";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
jQuery.each( tests, function( strFlags, resultString ) {
|
|
50
|
+
|
|
51
|
+
var objectFlags = {};
|
|
52
|
+
|
|
53
|
+
jQuery.each( strFlags.split( " " ), function() {
|
|
54
|
+
if ( this.length ) {
|
|
55
|
+
objectFlags[ this ] = true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
jQuery.each( filters, function( filterLabel, filter ) {
|
|
60
|
+
|
|
61
|
+
jQuery.each({
|
|
62
|
+
"string": strFlags,
|
|
63
|
+
"object": objectFlags
|
|
64
|
+
}, function( flagsTypes, flags ) {
|
|
65
|
+
|
|
66
|
+
test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() {
|
|
67
|
+
|
|
68
|
+
expect( 21 );
|
|
69
|
+
|
|
70
|
+
// Give qunit a little breathing room
|
|
71
|
+
stop();
|
|
72
|
+
setTimeout( start, 0 );
|
|
73
|
+
|
|
74
|
+
var cblist,
|
|
75
|
+
results = resultString.split( /\s+/ );
|
|
76
|
+
|
|
77
|
+
// Basic binding and firing
|
|
78
|
+
output = "X";
|
|
79
|
+
cblist = jQuery.Callbacks( flags );
|
|
80
|
+
cblist.add(function( str ) {
|
|
81
|
+
output += str;
|
|
82
|
+
});
|
|
83
|
+
cblist.fire("A");
|
|
84
|
+
strictEqual( output, "XA", "Basic binding and firing" );
|
|
85
|
+
strictEqual( cblist.fired(), true, ".fired() detects firing" );
|
|
86
|
+
output = "X";
|
|
87
|
+
cblist.disable();
|
|
88
|
+
cblist.add(function( str ) {
|
|
89
|
+
output += str;
|
|
90
|
+
});
|
|
91
|
+
strictEqual( output, "X", "Adding a callback after disabling" );
|
|
92
|
+
cblist.fire("A");
|
|
93
|
+
strictEqual( output, "X", "Firing after disabling" );
|
|
94
|
+
|
|
95
|
+
// Basic binding and firing (context, arguments)
|
|
96
|
+
output = "X";
|
|
97
|
+
cblist = jQuery.Callbacks( flags );
|
|
98
|
+
cblist.add(function() {
|
|
99
|
+
equal( this, window, "Basic binding and firing (context)" );
|
|
100
|
+
output += Array.prototype.join.call( arguments, "" );
|
|
101
|
+
});
|
|
102
|
+
cblist.fireWith( window, [ "A", "B" ] );
|
|
103
|
+
strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
|
|
104
|
+
|
|
105
|
+
// fireWith with no arguments
|
|
106
|
+
output = "";
|
|
107
|
+
cblist = jQuery.Callbacks( flags );
|
|
108
|
+
cblist.add(function() {
|
|
109
|
+
equal( this, window, "fireWith with no arguments (context is window)" );
|
|
110
|
+
strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
|
|
111
|
+
});
|
|
112
|
+
cblist.fireWith();
|
|
113
|
+
|
|
114
|
+
// Basic binding, removing and firing
|
|
115
|
+
output = "X";
|
|
116
|
+
cblist = jQuery.Callbacks( flags );
|
|
117
|
+
cblist.add( outputA, outputB, outputC );
|
|
118
|
+
cblist.remove( outputB, outputC );
|
|
119
|
+
cblist.fire();
|
|
120
|
+
strictEqual( output, "XA", "Basic binding, removing and firing" );
|
|
121
|
+
|
|
122
|
+
// Empty
|
|
123
|
+
output = "X";
|
|
124
|
+
cblist = jQuery.Callbacks( flags );
|
|
125
|
+
cblist.add( outputA );
|
|
126
|
+
cblist.add( outputB );
|
|
127
|
+
cblist.add( outputC );
|
|
128
|
+
cblist.empty();
|
|
129
|
+
cblist.fire();
|
|
130
|
+
strictEqual( output, "X", "Empty" );
|
|
131
|
+
|
|
132
|
+
// Locking
|
|
133
|
+
output = "X";
|
|
134
|
+
cblist = jQuery.Callbacks( flags );
|
|
135
|
+
cblist.add(function( str ) {
|
|
136
|
+
output += str;
|
|
137
|
+
});
|
|
138
|
+
cblist.lock();
|
|
139
|
+
cblist.add(function( str ) {
|
|
140
|
+
output += str;
|
|
141
|
+
});
|
|
142
|
+
cblist.fire("A");
|
|
143
|
+
cblist.add(function( str ) {
|
|
144
|
+
output += str;
|
|
145
|
+
});
|
|
146
|
+
strictEqual( output, "X", "Lock early" );
|
|
147
|
+
|
|
148
|
+
// Ordering
|
|
149
|
+
output = "X";
|
|
150
|
+
cblist = jQuery.Callbacks( flags );
|
|
151
|
+
cblist.add(function() {
|
|
152
|
+
cblist.add( outputC );
|
|
153
|
+
outputA();
|
|
154
|
+
}, outputB );
|
|
155
|
+
cblist.fire();
|
|
156
|
+
strictEqual( output, results.shift(), "Proper ordering" );
|
|
157
|
+
|
|
158
|
+
// Add and fire again
|
|
159
|
+
output = "X";
|
|
160
|
+
cblist.add(function() {
|
|
161
|
+
cblist.add( outputC );
|
|
162
|
+
outputA();
|
|
163
|
+
}, outputB );
|
|
164
|
+
strictEqual( output, results.shift(), "Add after fire" );
|
|
165
|
+
|
|
166
|
+
output = "X";
|
|
167
|
+
cblist.fire();
|
|
168
|
+
strictEqual( output, results.shift(), "Fire again" );
|
|
169
|
+
|
|
170
|
+
// Multiple fire
|
|
171
|
+
output = "X";
|
|
172
|
+
cblist = jQuery.Callbacks( flags );
|
|
173
|
+
cblist.add(function( str ) {
|
|
174
|
+
output += str;
|
|
175
|
+
});
|
|
176
|
+
cblist.fire("A");
|
|
177
|
+
strictEqual( output, "XA", "Multiple fire (first fire)" );
|
|
178
|
+
output = "X";
|
|
179
|
+
cblist.add(function( str ) {
|
|
180
|
+
output += str;
|
|
181
|
+
});
|
|
182
|
+
strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
|
|
183
|
+
output = "X";
|
|
184
|
+
cblist.fire("B");
|
|
185
|
+
strictEqual( output, results.shift(), "Multiple fire (second fire)" );
|
|
186
|
+
output = "X";
|
|
187
|
+
cblist.add(function( str ) {
|
|
188
|
+
output += str;
|
|
189
|
+
});
|
|
190
|
+
strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
|
|
191
|
+
|
|
192
|
+
// Return false
|
|
193
|
+
output = "X";
|
|
194
|
+
cblist = jQuery.Callbacks( flags );
|
|
195
|
+
cblist.add( outputA, function() { return false; }, outputB );
|
|
196
|
+
cblist.add( outputA );
|
|
197
|
+
cblist.fire();
|
|
198
|
+
strictEqual( output, results.shift(), "Callback returning false" );
|
|
199
|
+
|
|
200
|
+
// Add another callback (to control lists with memory do not fire anymore)
|
|
201
|
+
output = "X";
|
|
202
|
+
cblist.add( outputC );
|
|
203
|
+
strictEqual( output, results.shift(), "Adding a callback after one returned false" );
|
|
204
|
+
|
|
205
|
+
// Callbacks are not iterated
|
|
206
|
+
output = "";
|
|
207
|
+
function handler( tmp ) {
|
|
208
|
+
output += "X";
|
|
209
|
+
}
|
|
210
|
+
handler.method = function() {
|
|
211
|
+
output += "!";
|
|
212
|
+
};
|
|
213
|
+
cblist = jQuery.Callbacks( flags );
|
|
214
|
+
cblist.add( handler );
|
|
215
|
+
cblist.add( handler );
|
|
216
|
+
cblist.fire();
|
|
217
|
+
strictEqual( output, results.shift(), "No callback iteration" );
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
})();
|
|
224
|
+
|
|
225
|
+
test( "jQuery.Callbacks( options ) - options are copied", function() {
|
|
226
|
+
|
|
227
|
+
expect( 1 );
|
|
228
|
+
|
|
229
|
+
var options = {
|
|
230
|
+
"unique": true
|
|
231
|
+
},
|
|
232
|
+
cb = jQuery.Callbacks( options ),
|
|
233
|
+
count = 0,
|
|
234
|
+
fn = function() {
|
|
235
|
+
ok( !( count++ ), "called once" );
|
|
236
|
+
};
|
|
237
|
+
options["unique"] = false;
|
|
238
|
+
cb.add( fn, fn );
|
|
239
|
+
cb.fire();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
|
|
243
|
+
|
|
244
|
+
expect( 1 );
|
|
245
|
+
|
|
246
|
+
var cb = jQuery.Callbacks("memory"),
|
|
247
|
+
args = ["hello"];
|
|
248
|
+
|
|
249
|
+
cb.fireWith( null, args );
|
|
250
|
+
args[ 0 ] = "world";
|
|
251
|
+
|
|
252
|
+
cb.add(function( hello ) {
|
|
253
|
+
strictEqual( hello, "hello", "arguments are copied internally" );
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test( "jQuery.Callbacks.remove - should remove all instances", function() {
|
|
258
|
+
|
|
259
|
+
expect( 1 );
|
|
260
|
+
|
|
261
|
+
var cb = jQuery.Callbacks();
|
|
262
|
+
|
|
263
|
+
function fn() {
|
|
264
|
+
ok( false, "function wasn't removed" );
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
cb.add( fn, fn, function() {
|
|
268
|
+
ok( true, "end of test" );
|
|
269
|
+
}).remove( fn ).fire();
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test( "jQuery.Callbacks.has", function() {
|
|
273
|
+
|
|
274
|
+
expect( 13 );
|
|
275
|
+
|
|
276
|
+
var cb = jQuery.Callbacks();
|
|
277
|
+
function getA() {
|
|
278
|
+
return "A";
|
|
279
|
+
}
|
|
280
|
+
function getB() {
|
|
281
|
+
return "B";
|
|
282
|
+
}
|
|
283
|
+
function getC() {
|
|
284
|
+
return "C";
|
|
285
|
+
}
|
|
286
|
+
cb.add(getA, getB, getC);
|
|
287
|
+
strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" );
|
|
288
|
+
strictEqual( cb.has(getA), true, "Check if a specific callback function is in the Callbacks list" );
|
|
289
|
+
|
|
290
|
+
cb.remove(getB);
|
|
291
|
+
strictEqual( cb.has(getB), false, "Remove a specific callback function and make sure its no longer there" );
|
|
292
|
+
strictEqual( cb.has(getA), true, "Remove a specific callback function and make sure other callback function is still there" );
|
|
293
|
+
|
|
294
|
+
cb.empty();
|
|
295
|
+
strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" );
|
|
296
|
+
strictEqual( cb.has(getA), false, "Check for a specific function in an empty() list" );
|
|
297
|
+
|
|
298
|
+
cb.add(getA, getB, function(){
|
|
299
|
+
strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" );
|
|
300
|
+
strictEqual( cb.has(getA), true, "Check if list has a specific callback from within a callback function" );
|
|
301
|
+
}).fire();
|
|
302
|
+
|
|
303
|
+
strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" );
|
|
304
|
+
|
|
305
|
+
cb.disable();
|
|
306
|
+
strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" );
|
|
307
|
+
strictEqual( cb.has(getA), false, "Check for a specific function in a disabled() list" );
|
|
308
|
+
|
|
309
|
+
cb = jQuery.Callbacks("unique");
|
|
310
|
+
cb.add(getA);
|
|
311
|
+
cb.add(getA);
|
|
312
|
+
strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" );
|
|
313
|
+
cb.lock();
|
|
314
|
+
strictEqual( cb.has(), false, "locked() list is empty and returns false" );
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function() {
|
|
320
|
+
|
|
321
|
+
expect( 1 );
|
|
322
|
+
|
|
323
|
+
jQuery.Callbacks().add( "hello world" );
|
|
324
|
+
|
|
325
|
+
ok( true, "no stack overflow" );
|
|
326
|
+
});
|
|
@@ -0,0 +1,1332 @@
|
|
|
1
|
+
module("core", { teardown: moduleTeardown });
|
|
2
|
+
|
|
3
|
+
test("Unit Testing Environment", function () {
|
|
4
|
+
expect(2);
|
|
5
|
+
ok( hasPHP, "Running in an environment with PHP support. The AJAX tests only run if the environment supports PHP!" );
|
|
6
|
+
ok( !isLocal, "Unit tests are not ran from file:// (especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!)" );
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("Basic requirements", function() {
|
|
10
|
+
expect(7);
|
|
11
|
+
ok( Array.prototype.push, "Array.push()" );
|
|
12
|
+
ok( Function.prototype.apply, "Function.apply()" );
|
|
13
|
+
ok( document.getElementById, "getElementById" );
|
|
14
|
+
ok( document.getElementsByTagName, "getElementsByTagName" );
|
|
15
|
+
ok( RegExp, "RegExp" );
|
|
16
|
+
ok( jQuery, "jQuery" );
|
|
17
|
+
ok( $, "$" );
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/cc_on.html", function( cc_on, errors, $ ) {
|
|
21
|
+
expect( 3 );
|
|
22
|
+
ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) );
|
|
23
|
+
deepEqual( errors, [], "No errors" );
|
|
24
|
+
ok( $(), "jQuery executes" );
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("jQuery()", function() {
|
|
28
|
+
|
|
29
|
+
var elem, i,
|
|
30
|
+
obj = jQuery("div"),
|
|
31
|
+
main = jQuery("#qunit-fixture"),
|
|
32
|
+
code = jQuery("<code/>"),
|
|
33
|
+
img = jQuery("<img/>"),
|
|
34
|
+
div = jQuery("<div/><hr/><code/><b/>"),
|
|
35
|
+
exec = false,
|
|
36
|
+
lng = "",
|
|
37
|
+
expected = 21,
|
|
38
|
+
attrObj = {
|
|
39
|
+
"text": "test",
|
|
40
|
+
"class": "test2",
|
|
41
|
+
"id": "test3"
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// The $(html, props) signature can stealth-call any $.fn method, check for a
|
|
45
|
+
// few here but beware of modular builds where these methods may be excluded.
|
|
46
|
+
if ( jQuery.fn.click ) {
|
|
47
|
+
expected++;
|
|
48
|
+
attrObj["click"] = function() { ok( exec, "Click executed." ); };
|
|
49
|
+
}
|
|
50
|
+
if ( jQuery.fn.width ) {
|
|
51
|
+
expected++;
|
|
52
|
+
attrObj["width"] = 10;
|
|
53
|
+
}
|
|
54
|
+
if ( jQuery.fn.offset ) {
|
|
55
|
+
expected++;
|
|
56
|
+
attrObj["offset"] = { "top": 1, "left": 1 };
|
|
57
|
+
}
|
|
58
|
+
if ( jQuery.fn.css ) {
|
|
59
|
+
expected += 2;
|
|
60
|
+
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
|
|
61
|
+
}
|
|
62
|
+
if ( jQuery.fn.attr ) {
|
|
63
|
+
expected++;
|
|
64
|
+
attrObj.attr = { "desired": "very" };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
expect( expected );
|
|
68
|
+
|
|
69
|
+
// Basic constructor's behavior
|
|
70
|
+
equal( jQuery().length, 0, "jQuery() === jQuery([])" );
|
|
71
|
+
equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" );
|
|
72
|
+
equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" );
|
|
73
|
+
equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
|
|
74
|
+
equal( jQuery("#").length, 0, "jQuery('#') === jQuery([])" );
|
|
75
|
+
|
|
76
|
+
equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
|
|
77
|
+
|
|
78
|
+
// can actually yield more than one, when iframes are included, the window is an array as well
|
|
79
|
+
equal( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" );
|
|
80
|
+
|
|
81
|
+
deepEqual( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
// disabled since this test was doing nothing. i tried to fix it but i'm not sure
|
|
85
|
+
// what the expected behavior should even be. FF returns "\n" for the text node
|
|
86
|
+
// make sure this is handled
|
|
87
|
+
var crlfContainer = jQuery('<p>\r\n</p>');
|
|
88
|
+
var x = crlfContainer.contents().get(0).nodeValue;
|
|
89
|
+
equal( x, what???, "Check for \\r and \\n in jQuery()" );
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
/* // Disabled until we add this functionality in
|
|
93
|
+
var pass = true;
|
|
94
|
+
try {
|
|
95
|
+
jQuery("<div>Testing</div>").appendTo(document.getElementById("iframe").contentDocument.body);
|
|
96
|
+
} catch(e){
|
|
97
|
+
pass = false;
|
|
98
|
+
}
|
|
99
|
+
ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
|
|
100
|
+
|
|
101
|
+
equal( code.length, 1, "Correct number of elements generated for code" );
|
|
102
|
+
equal( code.parent().length, 0, "Make sure that the generated HTML has no parent." );
|
|
103
|
+
|
|
104
|
+
equal( img.length, 1, "Correct number of elements generated for img" );
|
|
105
|
+
equal( img.parent().length, 0, "Make sure that the generated HTML has no parent." );
|
|
106
|
+
|
|
107
|
+
equal( div.length, 4, "Correct number of elements generated for div hr code b" );
|
|
108
|
+
equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." );
|
|
109
|
+
|
|
110
|
+
equal( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" );
|
|
111
|
+
|
|
112
|
+
equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" );
|
|
113
|
+
|
|
114
|
+
elem = jQuery("<div/>", attrObj );
|
|
115
|
+
|
|
116
|
+
if ( jQuery.fn.width ) {
|
|
117
|
+
equal( elem[0].style.width, "10px", "jQuery() quick setter width");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if ( jQuery.fn.offset ) {
|
|
121
|
+
equal( elem[0].style.top, "1px", "jQuery() quick setter offset");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if ( jQuery.fn.css ) {
|
|
125
|
+
equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
|
|
126
|
+
equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ( jQuery.fn.attr ) {
|
|
130
|
+
equal( elem[0].getAttribute("desired"), "very", "jQuery quick setter attr");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
equal( elem[0].childNodes.length, 1, "jQuery quick setter text");
|
|
134
|
+
equal( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text");
|
|
135
|
+
equal( elem[0].className, "test2", "jQuery() quick setter class");
|
|
136
|
+
equal( elem[0].id, "test3", "jQuery() quick setter id");
|
|
137
|
+
|
|
138
|
+
exec = true;
|
|
139
|
+
elem.trigger("click");
|
|
140
|
+
|
|
141
|
+
// manually clean up detached elements
|
|
142
|
+
elem.remove();
|
|
143
|
+
|
|
144
|
+
for ( i = 0; i < 3; ++i ) {
|
|
145
|
+
elem = jQuery("<input type='text' value='TEST' />");
|
|
146
|
+
}
|
|
147
|
+
equal( elem[0].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" );
|
|
148
|
+
|
|
149
|
+
// manually clean up detached elements
|
|
150
|
+
elem.remove();
|
|
151
|
+
|
|
152
|
+
for ( i = 0; i < 128; i++ ) {
|
|
153
|
+
lng += "12345678";
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test( "selector state", function() {
|
|
158
|
+
expect( 18 );
|
|
159
|
+
|
|
160
|
+
var test;
|
|
161
|
+
|
|
162
|
+
test = jQuery( undefined );
|
|
163
|
+
equal( test.selector, "", "Empty jQuery Selector" );
|
|
164
|
+
equal( test.context, undefined, "Empty jQuery Context" );
|
|
165
|
+
|
|
166
|
+
test = jQuery( document );
|
|
167
|
+
equal( test.selector, "", "Document Selector" );
|
|
168
|
+
equal( test.context, document, "Document Context" );
|
|
169
|
+
|
|
170
|
+
test = jQuery( document.body );
|
|
171
|
+
equal( test.selector, "", "Body Selector" );
|
|
172
|
+
equal( test.context, document.body, "Body Context" );
|
|
173
|
+
|
|
174
|
+
test = jQuery("#qunit-fixture");
|
|
175
|
+
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
|
176
|
+
equal( test.context, document, "#qunit-fixture Context" );
|
|
177
|
+
|
|
178
|
+
test = jQuery("#notfoundnono");
|
|
179
|
+
equal( test.selector, "#notfoundnono", "#notfoundnono Selector" );
|
|
180
|
+
equal( test.context, document, "#notfoundnono Context" );
|
|
181
|
+
|
|
182
|
+
test = jQuery( "#qunit-fixture", document );
|
|
183
|
+
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
|
184
|
+
equal( test.context, document, "#qunit-fixture Context" );
|
|
185
|
+
|
|
186
|
+
test = jQuery( "#qunit-fixture", document.body );
|
|
187
|
+
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
|
188
|
+
equal( test.context, document.body, "#qunit-fixture Context" );
|
|
189
|
+
|
|
190
|
+
// Test cloning
|
|
191
|
+
test = jQuery( test );
|
|
192
|
+
equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
|
|
193
|
+
equal( test.context, document.body, "#qunit-fixture Context" );
|
|
194
|
+
|
|
195
|
+
test = jQuery( document.body ).find("#qunit-fixture");
|
|
196
|
+
equal( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" );
|
|
197
|
+
equal( test.context, document.body, "#qunit-fixture find Context" );
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test( "globalEval", function() {
|
|
201
|
+
expect( 3 );
|
|
202
|
+
Globals.register("globalEvalTest");
|
|
203
|
+
|
|
204
|
+
jQuery.globalEval("globalEvalTest = 1;");
|
|
205
|
+
equal( window.globalEvalTest, 1, "Test variable assignments are global" );
|
|
206
|
+
|
|
207
|
+
jQuery.globalEval("var globalEvalTest = 2;");
|
|
208
|
+
equal( window.globalEvalTest, 2, "Test variable declarations are global" );
|
|
209
|
+
|
|
210
|
+
jQuery.globalEval("this.globalEvalTest = 3;");
|
|
211
|
+
equal( window.globalEvalTest, 3, "Test context (this) is the window object" );
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("noConflict", function() {
|
|
215
|
+
expect(7);
|
|
216
|
+
|
|
217
|
+
var $$ = jQuery;
|
|
218
|
+
|
|
219
|
+
strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
|
|
220
|
+
strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." );
|
|
221
|
+
strictEqual( window["$"], original$, "Make sure $ was reverted." );
|
|
222
|
+
|
|
223
|
+
jQuery = $ = $$;
|
|
224
|
+
|
|
225
|
+
strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
|
|
226
|
+
strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." );
|
|
227
|
+
strictEqual( window["$"], original$, "Make sure $ was reverted." );
|
|
228
|
+
ok( $$().pushStack([]), "Make sure that jQuery still works." );
|
|
229
|
+
|
|
230
|
+
window["jQuery"] = jQuery = $$;
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("trim", function() {
|
|
234
|
+
expect(13);
|
|
235
|
+
|
|
236
|
+
var nbsp = String.fromCharCode(160);
|
|
237
|
+
|
|
238
|
+
equal( jQuery.trim("hello "), "hello", "trailing space" );
|
|
239
|
+
equal( jQuery.trim(" hello"), "hello", "leading space" );
|
|
240
|
+
equal( jQuery.trim(" hello "), "hello", "space on both sides" );
|
|
241
|
+
equal( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " );
|
|
242
|
+
|
|
243
|
+
equal( jQuery.trim(), "", "Nothing in." );
|
|
244
|
+
equal( jQuery.trim( undefined ), "", "Undefined" );
|
|
245
|
+
equal( jQuery.trim( null ), "", "Null" );
|
|
246
|
+
equal( jQuery.trim( 5 ), "5", "Number" );
|
|
247
|
+
equal( jQuery.trim( false ), "false", "Boolean" );
|
|
248
|
+
|
|
249
|
+
equal( jQuery.trim(" "), "", "space should be trimmed" );
|
|
250
|
+
equal( jQuery.trim("ipad\xA0"), "ipad", "nbsp should be trimmed" );
|
|
251
|
+
equal( jQuery.trim("\uFEFF"), "", "zwsp should be trimmed" );
|
|
252
|
+
equal( jQuery.trim("\uFEFF \xA0! | \uFEFF"), "! |", "leading/trailing should be trimmed" );
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("type", function() {
|
|
256
|
+
expect( 28 );
|
|
257
|
+
|
|
258
|
+
equal( jQuery.type(null), "null", "null" );
|
|
259
|
+
equal( jQuery.type(undefined), "undefined", "undefined" );
|
|
260
|
+
equal( jQuery.type(true), "boolean", "Boolean" );
|
|
261
|
+
equal( jQuery.type(false), "boolean", "Boolean" );
|
|
262
|
+
equal( jQuery.type(Boolean(true)), "boolean", "Boolean" );
|
|
263
|
+
equal( jQuery.type(0), "number", "Number" );
|
|
264
|
+
equal( jQuery.type(1), "number", "Number" );
|
|
265
|
+
equal( jQuery.type(Number(1)), "number", "Number" );
|
|
266
|
+
equal( jQuery.type(""), "string", "String" );
|
|
267
|
+
equal( jQuery.type("a"), "string", "String" );
|
|
268
|
+
equal( jQuery.type(String("a")), "string", "String" );
|
|
269
|
+
equal( jQuery.type({}), "object", "Object" );
|
|
270
|
+
equal( jQuery.type(/foo/), "regexp", "RegExp" );
|
|
271
|
+
equal( jQuery.type(new RegExp("asdf")), "regexp", "RegExp" );
|
|
272
|
+
equal( jQuery.type([1]), "array", "Array" );
|
|
273
|
+
equal( jQuery.type(new Date()), "date", "Date" );
|
|
274
|
+
equal( jQuery.type(new Function("return;")), "function", "Function" );
|
|
275
|
+
equal( jQuery.type(function(){}), "function", "Function" );
|
|
276
|
+
equal( jQuery.type(new Error()), "error", "Error" );
|
|
277
|
+
equal( jQuery.type(window), "object", "Window" );
|
|
278
|
+
equal( jQuery.type(document), "object", "Document" );
|
|
279
|
+
equal( jQuery.type(document.body), "object", "Element" );
|
|
280
|
+
equal( jQuery.type(document.createTextNode("foo")), "object", "TextNode" );
|
|
281
|
+
equal( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" );
|
|
282
|
+
|
|
283
|
+
// Avoid Lint complaints
|
|
284
|
+
var MyString = String;
|
|
285
|
+
var MyNumber = Number;
|
|
286
|
+
var MyBoolean = Boolean;
|
|
287
|
+
var MyObject = Object;
|
|
288
|
+
equal( jQuery.type(new MyBoolean(true)), "boolean", "Boolean" );
|
|
289
|
+
equal( jQuery.type(new MyNumber(1)), "number", "Number" );
|
|
290
|
+
equal( jQuery.type(new MyString("a")), "string", "String" );
|
|
291
|
+
equal( jQuery.type(new MyObject()), "object", "Object" );
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
asyncTest("isPlainObject", function() {
|
|
295
|
+
expect(15);
|
|
296
|
+
|
|
297
|
+
var pass, iframe, doc,
|
|
298
|
+
fn = function() {};
|
|
299
|
+
|
|
300
|
+
// The use case that we want to match
|
|
301
|
+
ok( jQuery.isPlainObject({}), "{}" );
|
|
302
|
+
|
|
303
|
+
// Not objects shouldn't be matched
|
|
304
|
+
ok( !jQuery.isPlainObject(""), "string" );
|
|
305
|
+
ok( !jQuery.isPlainObject(0) && !jQuery.isPlainObject(1), "number" );
|
|
306
|
+
ok( !jQuery.isPlainObject(true) && !jQuery.isPlainObject(false), "boolean" );
|
|
307
|
+
ok( !jQuery.isPlainObject(null), "null" );
|
|
308
|
+
ok( !jQuery.isPlainObject(undefined), "undefined" );
|
|
309
|
+
|
|
310
|
+
// Arrays shouldn't be matched
|
|
311
|
+
ok( !jQuery.isPlainObject([]), "array" );
|
|
312
|
+
|
|
313
|
+
// Instantiated objects shouldn't be matched
|
|
314
|
+
ok( !jQuery.isPlainObject(new Date()), "new Date" );
|
|
315
|
+
|
|
316
|
+
// Functions shouldn't be matched
|
|
317
|
+
ok( !jQuery.isPlainObject(fn), "fn" );
|
|
318
|
+
|
|
319
|
+
// Again, instantiated objects shouldn't be matched
|
|
320
|
+
ok( !jQuery.isPlainObject(new fn()), "new fn (no methods)" );
|
|
321
|
+
|
|
322
|
+
// Makes the function a little more realistic
|
|
323
|
+
// (and harder to detect, incidentally)
|
|
324
|
+
fn.prototype["someMethod"] = function(){};
|
|
325
|
+
|
|
326
|
+
// Again, instantiated objects shouldn't be matched
|
|
327
|
+
ok( !jQuery.isPlainObject(new fn()), "new fn" );
|
|
328
|
+
|
|
329
|
+
// DOM Element
|
|
330
|
+
ok( !jQuery.isPlainObject( document.createElement("div") ), "DOM Element" );
|
|
331
|
+
|
|
332
|
+
// Window
|
|
333
|
+
ok( !jQuery.isPlainObject( window ), "window" );
|
|
334
|
+
|
|
335
|
+
pass = false;
|
|
336
|
+
try {
|
|
337
|
+
jQuery.isPlainObject( window.location );
|
|
338
|
+
pass = true;
|
|
339
|
+
} catch ( e ) {}
|
|
340
|
+
ok( pass, "Does not throw exceptions on host objects" );
|
|
341
|
+
|
|
342
|
+
// Objects from other windows should be matched
|
|
343
|
+
window.iframeCallback = function( otherObject, detail ) {
|
|
344
|
+
window.iframeCallback = undefined;
|
|
345
|
+
iframe.parentNode.removeChild( iframe );
|
|
346
|
+
ok( jQuery.isPlainObject(new otherObject()), "new otherObject" + ( detail ? " - " + detail : "" ) );
|
|
347
|
+
start();
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
try {
|
|
351
|
+
iframe = jQuery("#qunit-fixture")[0].appendChild( document.createElement("iframe") );
|
|
352
|
+
doc = iframe.contentDocument || iframe.contentWindow.document;
|
|
353
|
+
doc.open();
|
|
354
|
+
doc.write("<body onload='window.parent.iframeCallback(Object);'>");
|
|
355
|
+
doc.close();
|
|
356
|
+
} catch(e) {
|
|
357
|
+
window.iframeDone( Object, "iframes not supported" );
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
test("isFunction", function() {
|
|
362
|
+
expect(19);
|
|
363
|
+
|
|
364
|
+
// Make sure that false values return false
|
|
365
|
+
ok( !jQuery.isFunction(), "No Value" );
|
|
366
|
+
ok( !jQuery.isFunction( null ), "null Value" );
|
|
367
|
+
ok( !jQuery.isFunction( undefined ), "undefined Value" );
|
|
368
|
+
ok( !jQuery.isFunction( "" ), "Empty String Value" );
|
|
369
|
+
ok( !jQuery.isFunction( 0 ), "0 Value" );
|
|
370
|
+
|
|
371
|
+
// Check built-ins
|
|
372
|
+
// Safari uses "(Internal Function)"
|
|
373
|
+
ok( jQuery.isFunction(String), "String Function("+String+")" );
|
|
374
|
+
ok( jQuery.isFunction(Array), "Array Function("+Array+")" );
|
|
375
|
+
ok( jQuery.isFunction(Object), "Object Function("+Object+")" );
|
|
376
|
+
ok( jQuery.isFunction(Function), "Function Function("+Function+")" );
|
|
377
|
+
|
|
378
|
+
// When stringified, this could be misinterpreted
|
|
379
|
+
var mystr = "function";
|
|
380
|
+
ok( !jQuery.isFunction(mystr), "Function String" );
|
|
381
|
+
|
|
382
|
+
// When stringified, this could be misinterpreted
|
|
383
|
+
var myarr = [ "function" ];
|
|
384
|
+
ok( !jQuery.isFunction(myarr), "Function Array" );
|
|
385
|
+
|
|
386
|
+
// When stringified, this could be misinterpreted
|
|
387
|
+
var myfunction = { "function": "test" };
|
|
388
|
+
ok( !jQuery.isFunction(myfunction), "Function Object" );
|
|
389
|
+
|
|
390
|
+
// Make sure normal functions still work
|
|
391
|
+
var fn = function(){};
|
|
392
|
+
ok( jQuery.isFunction(fn), "Normal Function" );
|
|
393
|
+
|
|
394
|
+
var obj = document.createElement("object");
|
|
395
|
+
|
|
396
|
+
// Firefox says this is a function
|
|
397
|
+
ok( !jQuery.isFunction(obj), "Object Element" );
|
|
398
|
+
|
|
399
|
+
// IE says this is an object
|
|
400
|
+
// Since 1.3, this isn't supported (#2968)
|
|
401
|
+
//ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );
|
|
402
|
+
|
|
403
|
+
var nodes = document.body.childNodes;
|
|
404
|
+
|
|
405
|
+
// Safari says this is a function
|
|
406
|
+
ok( !jQuery.isFunction(nodes), "childNodes Property" );
|
|
407
|
+
|
|
408
|
+
var first = document.body.firstChild;
|
|
409
|
+
|
|
410
|
+
// Normal elements are reported ok everywhere
|
|
411
|
+
ok( !jQuery.isFunction(first), "A normal DOM Element" );
|
|
412
|
+
|
|
413
|
+
var input = document.createElement("input");
|
|
414
|
+
input.type = "text";
|
|
415
|
+
document.body.appendChild( input );
|
|
416
|
+
|
|
417
|
+
// IE says this is an object
|
|
418
|
+
// Since 1.3, this isn't supported (#2968)
|
|
419
|
+
//ok( jQuery.isFunction(input.focus), "A default function property" );
|
|
420
|
+
|
|
421
|
+
document.body.removeChild( input );
|
|
422
|
+
|
|
423
|
+
var a = document.createElement("a");
|
|
424
|
+
a.href = "some-function";
|
|
425
|
+
document.body.appendChild( a );
|
|
426
|
+
|
|
427
|
+
// This serializes with the word 'function' in it
|
|
428
|
+
ok( !jQuery.isFunction(a), "Anchor Element" );
|
|
429
|
+
|
|
430
|
+
document.body.removeChild( a );
|
|
431
|
+
|
|
432
|
+
// Recursive function calls have lengths and array-like properties
|
|
433
|
+
function callme(callback){
|
|
434
|
+
function fn(response){
|
|
435
|
+
callback(response);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
ok( jQuery.isFunction(fn), "Recursive Function Call" );
|
|
439
|
+
|
|
440
|
+
fn({ some: "data" });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
callme(function(){
|
|
444
|
+
callme(function(){});
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test( "isNumeric", function() {
|
|
449
|
+
expect( 36 );
|
|
450
|
+
|
|
451
|
+
var t = jQuery.isNumeric,
|
|
452
|
+
Traditionalists = /** @constructor */ function(n) {
|
|
453
|
+
this.value = n;
|
|
454
|
+
this.toString = function(){
|
|
455
|
+
return String(this.value);
|
|
456
|
+
};
|
|
457
|
+
},
|
|
458
|
+
answer = new Traditionalists( "42" ),
|
|
459
|
+
rong = new Traditionalists( "Devo" );
|
|
460
|
+
|
|
461
|
+
ok( t("-10"), "Negative integer string");
|
|
462
|
+
ok( t("0"), "Zero string");
|
|
463
|
+
ok( t("5"), "Positive integer string");
|
|
464
|
+
ok( t(-16), "Negative integer number");
|
|
465
|
+
ok( t(0), "Zero integer number");
|
|
466
|
+
ok( t(32), "Positive integer number");
|
|
467
|
+
ok( t("040"), "Octal integer literal string");
|
|
468
|
+
// OctalIntegerLiteral has been deprecated since ES3/1999
|
|
469
|
+
// It doesn't pass lint, so disabling until a solution can be found
|
|
470
|
+
//ok( t(0144), "Octal integer literal");
|
|
471
|
+
ok( t("0xFF"), "Hexadecimal integer literal string");
|
|
472
|
+
ok( t(0xFFF), "Hexadecimal integer literal");
|
|
473
|
+
ok( t("-1.6"), "Negative floating point string");
|
|
474
|
+
ok( t("4.536"), "Positive floating point string");
|
|
475
|
+
ok( t(-2.6), "Negative floating point number");
|
|
476
|
+
ok( t(3.1415), "Positive floating point number");
|
|
477
|
+
ok( t(8e5), "Exponential notation");
|
|
478
|
+
ok( t("123e-2"), "Exponential notation string");
|
|
479
|
+
ok( t(answer), "Custom .toString returning number");
|
|
480
|
+
equal( t(""), false, "Empty string");
|
|
481
|
+
equal( t(" "), false, "Whitespace characters string");
|
|
482
|
+
equal( t("\t\t"), false, "Tab characters string");
|
|
483
|
+
equal( t("abcdefghijklm1234567890"), false, "Alphanumeric character string");
|
|
484
|
+
equal( t("xabcdefx"), false, "Non-numeric character string");
|
|
485
|
+
equal( t(true), false, "Boolean true literal");
|
|
486
|
+
equal( t(false), false, "Boolean false literal");
|
|
487
|
+
equal( t("bcfed5.2"), false, "Number with preceding non-numeric characters");
|
|
488
|
+
equal( t("7.2acdgs"), false, "Number with trailling non-numeric characters");
|
|
489
|
+
equal( t(undefined), false, "Undefined value");
|
|
490
|
+
equal( t(null), false, "Null value");
|
|
491
|
+
equal( t(NaN), false, "NaN value");
|
|
492
|
+
equal( t(Infinity), false, "Infinity primitive");
|
|
493
|
+
equal( t(Number.POSITIVE_INFINITY), false, "Positive Infinity");
|
|
494
|
+
equal( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity");
|
|
495
|
+
equal( t(rong), false, "Custom .toString returning non-number");
|
|
496
|
+
equal( t({}), false, "Empty object");
|
|
497
|
+
equal( t(function(){} ), false, "Instance of a function");
|
|
498
|
+
equal( t( new Date() ), false, "Instance of a Date");
|
|
499
|
+
equal( t(function(){} ), false, "Instance of a function");
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
test("isXMLDoc - HTML", function() {
|
|
503
|
+
expect(4);
|
|
504
|
+
|
|
505
|
+
ok( !jQuery.isXMLDoc( document ), "HTML document" );
|
|
506
|
+
ok( !jQuery.isXMLDoc( document.documentElement ), "HTML documentElement" );
|
|
507
|
+
ok( !jQuery.isXMLDoc( document.body ), "HTML Body Element" );
|
|
508
|
+
|
|
509
|
+
var iframe = document.createElement("iframe");
|
|
510
|
+
document.body.appendChild( iframe );
|
|
511
|
+
|
|
512
|
+
try {
|
|
513
|
+
var body = jQuery(iframe).contents()[0];
|
|
514
|
+
|
|
515
|
+
try {
|
|
516
|
+
ok( !jQuery.isXMLDoc( body ), "Iframe body element" );
|
|
517
|
+
} catch(e) {
|
|
518
|
+
ok( false, "Iframe body element exception" );
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
} catch(e) {
|
|
522
|
+
ok( true, "Iframe body element - iframe not working correctly" );
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
document.body.removeChild( iframe );
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
test("XSS via location.hash", function() {
|
|
529
|
+
expect(1);
|
|
530
|
+
|
|
531
|
+
stop();
|
|
532
|
+
jQuery["_check9521"] = function(x){
|
|
533
|
+
ok( x, "script called from #id-like selector with inline handler" );
|
|
534
|
+
jQuery("#check9521").remove();
|
|
535
|
+
delete jQuery["_check9521"];
|
|
536
|
+
start();
|
|
537
|
+
};
|
|
538
|
+
try {
|
|
539
|
+
// This throws an error because it's processed like an id
|
|
540
|
+
jQuery( "#<img id='check9521' src='no-such-.gif' onerror='jQuery._check9521(false)'>" ).appendTo("#qunit-fixture");
|
|
541
|
+
} catch (err) {
|
|
542
|
+
jQuery["_check9521"](true);
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
test("isXMLDoc - XML", function() {
|
|
547
|
+
expect(3);
|
|
548
|
+
var xml = createDashboardXML();
|
|
549
|
+
ok( jQuery.isXMLDoc( xml ), "XML document" );
|
|
550
|
+
ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" );
|
|
551
|
+
ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" );
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
test("isWindow", function() {
|
|
555
|
+
expect( 14 );
|
|
556
|
+
|
|
557
|
+
ok( jQuery.isWindow(window), "window" );
|
|
558
|
+
ok( jQuery.isWindow(document.getElementsByTagName("iframe")[0].contentWindow), "iframe.contentWindow" );
|
|
559
|
+
ok( !jQuery.isWindow(), "empty" );
|
|
560
|
+
ok( !jQuery.isWindow(null), "null" );
|
|
561
|
+
ok( !jQuery.isWindow(undefined), "undefined" );
|
|
562
|
+
ok( !jQuery.isWindow(document), "document" );
|
|
563
|
+
ok( !jQuery.isWindow(document.documentElement), "documentElement" );
|
|
564
|
+
ok( !jQuery.isWindow(""), "string" );
|
|
565
|
+
ok( !jQuery.isWindow(1), "number" );
|
|
566
|
+
ok( !jQuery.isWindow(true), "boolean" );
|
|
567
|
+
ok( !jQuery.isWindow({}), "object" );
|
|
568
|
+
ok( !jQuery.isWindow({ setInterval: function(){} }), "fake window" );
|
|
569
|
+
ok( !jQuery.isWindow(/window/), "regexp" );
|
|
570
|
+
ok( !jQuery.isWindow(function(){}), "function" );
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
test("jQuery('html')", function() {
|
|
574
|
+
expect( 15 );
|
|
575
|
+
|
|
576
|
+
QUnit.reset();
|
|
577
|
+
jQuery["foo"] = false;
|
|
578
|
+
var s = jQuery("<script>jQuery.foo='test';</script>")[0];
|
|
579
|
+
ok( s, "Creating a script" );
|
|
580
|
+
ok( !jQuery["foo"], "Make sure the script wasn't executed prematurely" );
|
|
581
|
+
jQuery("body").append("<script>jQuery.foo='test';</script>");
|
|
582
|
+
ok( jQuery["foo"], "Executing a scripts contents in the right context" );
|
|
583
|
+
|
|
584
|
+
// Test multi-line HTML
|
|
585
|
+
var div = jQuery("<div>\r\nsome text\n<p>some p</p>\nmore text\r\n</div>")[0];
|
|
586
|
+
equal( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." );
|
|
587
|
+
equal( div.firstChild.nodeType, 3, "Text node." );
|
|
588
|
+
equal( div.lastChild.nodeType, 3, "Text node." );
|
|
589
|
+
equal( div.childNodes[1].nodeType, 1, "Paragraph." );
|
|
590
|
+
equal( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." );
|
|
591
|
+
|
|
592
|
+
QUnit.reset();
|
|
593
|
+
ok( jQuery("<link rel='stylesheet'/>")[0], "Creating a link" );
|
|
594
|
+
|
|
595
|
+
ok( !jQuery("<script/>")[0].parentNode, "Create a script" );
|
|
596
|
+
|
|
597
|
+
ok( jQuery("<input/>").attr("type", "hidden"), "Create an input and set the type." );
|
|
598
|
+
|
|
599
|
+
var j = jQuery("<span>hi</span> there <!-- mon ami -->");
|
|
600
|
+
ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" );
|
|
601
|
+
|
|
602
|
+
ok( !jQuery("<option>test</option>")[0].selected, "Make sure that options are auto-selected #2050" );
|
|
603
|
+
|
|
604
|
+
ok( jQuery("<div></div>")[0], "Create a div with closing tag." );
|
|
605
|
+
ok( jQuery("<table></table>")[0], "Create a table with closing tag." );
|
|
606
|
+
|
|
607
|
+
// equal( jQuery("element[attribute='<div></div>']").length, 0, "When html is within brackets, do not recognize as html." );
|
|
608
|
+
// equal( jQuery("element[attribute=<div></div>]").length, 0, "When html is within brackets, do not recognize as html." );
|
|
609
|
+
// equal( jQuery("element:not(<div></div>)").length, 0, "When html is within parens, do not recognize as html." );
|
|
610
|
+
// equal( jQuery("\\<div\\>").length, 0, "Ignore escaped html characters" );
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
test("jQuery('massive html #7990')", function() {
|
|
614
|
+
expect( 3 );
|
|
615
|
+
|
|
616
|
+
var i;
|
|
617
|
+
var li = "<li>very very very very large html string</li>";
|
|
618
|
+
var html = ["<ul>"];
|
|
619
|
+
for ( i = 0; i < 30000; i += 1 ) {
|
|
620
|
+
html[html.length] = li;
|
|
621
|
+
}
|
|
622
|
+
html[html.length] = "</ul>";
|
|
623
|
+
html = jQuery(html.join(""))[0];
|
|
624
|
+
equal( html.nodeName.toLowerCase(), "ul");
|
|
625
|
+
equal( html.firstChild.nodeName.toLowerCase(), "li");
|
|
626
|
+
equal( html.childNodes.length, 30000 );
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
test("jQuery('html', context)", function() {
|
|
630
|
+
expect(1);
|
|
631
|
+
|
|
632
|
+
var $div = jQuery("<div/>")[0];
|
|
633
|
+
var $span = jQuery("<span/>", $div);
|
|
634
|
+
equal($span.length, 1, "Verify a span created with a div context works, #1763");
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
|
|
638
|
+
expect(2);
|
|
639
|
+
|
|
640
|
+
var xml = createDashboardXML();
|
|
641
|
+
// tests for #1419 where IE was a problem
|
|
642
|
+
var tab = jQuery("tab", xml).eq(0);
|
|
643
|
+
equal( tab.text(), "blabla", "Verify initial text correct" );
|
|
644
|
+
tab.text("newtext");
|
|
645
|
+
equal( tab.text(), "newtext", "Verify new text correct" );
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
test("end()", function() {
|
|
649
|
+
expect(3);
|
|
650
|
+
equal( "Yahoo", jQuery("#yahoo").parent().end().text(), "Check for end" );
|
|
651
|
+
ok( jQuery("#yahoo").end(), "Check for end with nothing to end" );
|
|
652
|
+
|
|
653
|
+
var x = jQuery("#yahoo");
|
|
654
|
+
x.parent();
|
|
655
|
+
equal( "Yahoo", jQuery("#yahoo").text(), "Check for non-destructive behaviour" );
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
test("length", function() {
|
|
659
|
+
expect(1);
|
|
660
|
+
equal( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" );
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
test("size()", function() {
|
|
664
|
+
expect(1);
|
|
665
|
+
equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
test("get()", function() {
|
|
669
|
+
expect(1);
|
|
670
|
+
deepEqual( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
test("toArray()", function() {
|
|
674
|
+
expect(1);
|
|
675
|
+
deepEqual( jQuery("#qunit-fixture p").toArray(),
|
|
676
|
+
q("firstp","ap","sndp","en","sap","first"),
|
|
677
|
+
"Convert jQuery object to an Array" );
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
test("inArray()", function() {
|
|
681
|
+
expect(19);
|
|
682
|
+
|
|
683
|
+
var selections = {
|
|
684
|
+
p: q("firstp", "sap", "ap", "first"),
|
|
685
|
+
em: q("siblingnext", "siblingfirst"),
|
|
686
|
+
div: q("qunit-testrunner-toolbar", "nothiddendiv", "nothiddendivchild", "foo"),
|
|
687
|
+
a: q("mark", "groups", "google", "simon1"),
|
|
688
|
+
empty: []
|
|
689
|
+
},
|
|
690
|
+
tests = {
|
|
691
|
+
p: { elem: jQuery("#ap")[0], index: 2 },
|
|
692
|
+
em: { elem: jQuery("#siblingfirst")[0], index: 1 },
|
|
693
|
+
div: { elem: jQuery("#nothiddendiv")[0], index: 1 },
|
|
694
|
+
a: { elem: jQuery("#simon1")[0], index: 3 }
|
|
695
|
+
},
|
|
696
|
+
falseTests = {
|
|
697
|
+
p: jQuery("#liveSpan1")[0],
|
|
698
|
+
em: jQuery("#nothiddendiv")[0],
|
|
699
|
+
empty: ""
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
jQuery.each( tests, function( key, obj ) {
|
|
703
|
+
equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" );
|
|
704
|
+
// Third argument (fromIndex)
|
|
705
|
+
equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" );
|
|
706
|
+
equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" );
|
|
707
|
+
equal( !!~jQuery.inArray( obj.elem, selections[ key ], -3 ), true, "elem is in the array of selections given a negative index" );
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
jQuery.each( falseTests, function( key, elem ) {
|
|
711
|
+
equal( !!~jQuery.inArray( elem, selections[ key ] ), false, "elem is NOT in the array of selections" );
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
test("get(Number)", function() {
|
|
717
|
+
expect(2);
|
|
718
|
+
equal( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" );
|
|
719
|
+
strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" );
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
test("get(-Number)",function() {
|
|
723
|
+
expect(2);
|
|
724
|
+
equal( jQuery("p").get(-1), document.getElementById("first"), "Get a single element with negative index" );
|
|
725
|
+
strictEqual( jQuery("#firstp").get(-2), undefined, "Try get with index negative index larger then elements count" );
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
test("each(Function)", function() {
|
|
729
|
+
expect(1);
|
|
730
|
+
var div = jQuery("div");
|
|
731
|
+
div.each(function(){this.foo = "zoo";});
|
|
732
|
+
var pass = true;
|
|
733
|
+
for ( var i = 0; i < div.size(); i++ ) {
|
|
734
|
+
if ( div.get(i).foo != "zoo" ) {
|
|
735
|
+
pass = false;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
ok( pass, "Execute a function, Relative" );
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
test("slice()", function() {
|
|
742
|
+
expect(7);
|
|
743
|
+
|
|
744
|
+
var $links = jQuery("#ap a");
|
|
745
|
+
|
|
746
|
+
deepEqual( $links.slice(1,2).get(), q("groups"), "slice(1,2)" );
|
|
747
|
+
deepEqual( $links.slice(1).get(), q("groups", "anchor1", "mark"), "slice(1)" );
|
|
748
|
+
deepEqual( $links.slice(0,3).get(), q("google", "groups", "anchor1"), "slice(0,3)" );
|
|
749
|
+
deepEqual( $links.slice(-1).get(), q("mark"), "slice(-1)" );
|
|
750
|
+
|
|
751
|
+
deepEqual( $links.eq(1).get(), q("groups"), "eq(1)" );
|
|
752
|
+
deepEqual( $links.eq("2").get(), q("anchor1"), "eq('2')" );
|
|
753
|
+
deepEqual( $links.eq(-1).get(), q("mark"), "eq(-1)" );
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
test("first()/last()", function() {
|
|
757
|
+
expect(4);
|
|
758
|
+
|
|
759
|
+
var $links = jQuery("#ap a"), $none = jQuery("asdf");
|
|
760
|
+
|
|
761
|
+
deepEqual( $links.first().get(), q("google"), "first()" );
|
|
762
|
+
deepEqual( $links.last().get(), q("mark"), "last()" );
|
|
763
|
+
|
|
764
|
+
deepEqual( $none.first().get(), [], "first() none" );
|
|
765
|
+
deepEqual( $none.last().get(), [], "last() none" );
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
test("map()", function() {
|
|
769
|
+
expect( 2 );
|
|
770
|
+
|
|
771
|
+
deepEqual(
|
|
772
|
+
jQuery("#ap").map(function() {
|
|
773
|
+
return jQuery( this ).find("a").get();
|
|
774
|
+
}).get(),
|
|
775
|
+
q( "google", "groups", "anchor1", "mark" ),
|
|
776
|
+
"Array Map"
|
|
777
|
+
);
|
|
778
|
+
|
|
779
|
+
deepEqual(
|
|
780
|
+
jQuery("#ap > a").map(function() {
|
|
781
|
+
return this.parentNode;
|
|
782
|
+
}).get(),
|
|
783
|
+
q( "ap","ap","ap" ),
|
|
784
|
+
"Single Map"
|
|
785
|
+
);
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
test("jQuery.map", function() {
|
|
789
|
+
expect( 25 );
|
|
790
|
+
|
|
791
|
+
var i, label, result, callback;
|
|
792
|
+
|
|
793
|
+
result = jQuery.map( [ 3, 4, 5 ], function( v, k ) {
|
|
794
|
+
return k;
|
|
795
|
+
});
|
|
796
|
+
equal( result.join(""), "012", "Map the keys from an array" );
|
|
797
|
+
|
|
798
|
+
result = jQuery.map( [ 3, 4, 5 ], function( v, k ) {
|
|
799
|
+
return v;
|
|
800
|
+
});
|
|
801
|
+
equal( result.join(""), "345", "Map the values from an array" );
|
|
802
|
+
|
|
803
|
+
result = jQuery.map( { a: 1, b: 2 }, function( v, k ) {
|
|
804
|
+
return k;
|
|
805
|
+
});
|
|
806
|
+
equal( result.join(""), "ab", "Map the keys from an object" );
|
|
807
|
+
|
|
808
|
+
result = jQuery.map( { a: 1, b: 2 }, function( v, k ) {
|
|
809
|
+
return v;
|
|
810
|
+
});
|
|
811
|
+
equal( result.join(""), "12", "Map the values from an object" );
|
|
812
|
+
|
|
813
|
+
result = jQuery.map( [ "a", undefined, null, "b" ], function( v, k ) {
|
|
814
|
+
return v;
|
|
815
|
+
});
|
|
816
|
+
equal( result.join(""), "ab", "Array iteration does not include undefined/null results" );
|
|
817
|
+
|
|
818
|
+
result = jQuery.map( { a: "a", b: undefined, c: null, d: "b" }, function( v, k ) {
|
|
819
|
+
return v;
|
|
820
|
+
});
|
|
821
|
+
equal( result.join(""), "ab", "Object iteration does not include undefined/null results" );
|
|
822
|
+
|
|
823
|
+
result = {
|
|
824
|
+
Zero: function() {},
|
|
825
|
+
One: function( a ) {},
|
|
826
|
+
Two: function( a, b ) {}
|
|
827
|
+
};
|
|
828
|
+
callback = function( v, k ) {
|
|
829
|
+
equal( k, "foo", label + "-argument function treated like object" );
|
|
830
|
+
};
|
|
831
|
+
for ( i in result ) {
|
|
832
|
+
label = i;
|
|
833
|
+
result[ i ].foo = "bar";
|
|
834
|
+
jQuery.map( result[ i ], callback );
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
result = {
|
|
838
|
+
"undefined": undefined,
|
|
839
|
+
"null": null,
|
|
840
|
+
"false": false,
|
|
841
|
+
"true": true,
|
|
842
|
+
"empty string": "",
|
|
843
|
+
"nonempty string": "string",
|
|
844
|
+
"string \"0\"": "0",
|
|
845
|
+
"negative": -1,
|
|
846
|
+
"excess": 1
|
|
847
|
+
};
|
|
848
|
+
callback = function( v, k ) {
|
|
849
|
+
equal( k, "length", "Object with " + label + " length treated like object" );
|
|
850
|
+
};
|
|
851
|
+
for ( i in result ) {
|
|
852
|
+
label = i;
|
|
853
|
+
jQuery.map( { length: result[ i ] }, callback );
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
result = {
|
|
857
|
+
"sparse Array": Array( 4 ),
|
|
858
|
+
"length: 1 plain object": { length: 1, "0": true },
|
|
859
|
+
"length: 2 plain object": { length: 2, "0": true, "1": true },
|
|
860
|
+
NodeList: document.getElementsByTagName("html")
|
|
861
|
+
};
|
|
862
|
+
callback = function( v, k ) {
|
|
863
|
+
if ( result[ label ] ) {
|
|
864
|
+
delete result[ label ];
|
|
865
|
+
equal( k, "0", label + " treated like array" );
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
for ( i in result ) {
|
|
869
|
+
label = i;
|
|
870
|
+
jQuery.map( result[ i ], callback );
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
result = false;
|
|
874
|
+
jQuery.map( { length: 0 }, function( v, k ) {
|
|
875
|
+
result = true;
|
|
876
|
+
});
|
|
877
|
+
ok( !result, "length: 0 plain object treated like array" );
|
|
878
|
+
|
|
879
|
+
result = false;
|
|
880
|
+
jQuery.map( document.getElementsByTagName("asdf"), function( v, k ) {
|
|
881
|
+
result = true;
|
|
882
|
+
});
|
|
883
|
+
ok( !result, "empty NodeList treated like array" );
|
|
884
|
+
|
|
885
|
+
result = jQuery.map( Array(4), function( v, k ){
|
|
886
|
+
return k % 2 ? k : [k,k,k];
|
|
887
|
+
});
|
|
888
|
+
equal( result.join(""), "00012223", "Array results flattened (#2616)" );
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
test("jQuery.merge()", function() {
|
|
892
|
+
expect(8);
|
|
893
|
+
|
|
894
|
+
deepEqual( jQuery.merge([],[]), [], "Empty arrays" );
|
|
895
|
+
|
|
896
|
+
deepEqual( jQuery.merge([ 1 ],[ 2 ]), [ 1, 2 ], "Basic" );
|
|
897
|
+
deepEqual( jQuery.merge([ 1, 2 ], [ 3, 4 ]), [ 1, 2, 3, 4 ], "Basic" );
|
|
898
|
+
|
|
899
|
+
deepEqual( jQuery.merge([ 1, 2 ],[]), [ 1, 2 ], "Second empty" );
|
|
900
|
+
deepEqual( jQuery.merge([],[ 1, 2 ]), [ 1, 2 ], "First empty" );
|
|
901
|
+
|
|
902
|
+
// Fixed at [5998], #3641
|
|
903
|
+
deepEqual( jQuery.merge([ -2, -1 ], [ 0, 1, 2 ]), [ -2, -1 , 0, 1, 2 ],
|
|
904
|
+
"Second array including a zero (falsy)");
|
|
905
|
+
|
|
906
|
+
// After fixing #5527
|
|
907
|
+
deepEqual( jQuery.merge([], [ null, undefined ]), [ null, undefined ],
|
|
908
|
+
"Second array including null and undefined values");
|
|
909
|
+
deepEqual( jQuery.merge({ length: 0 }, [ 1, 2 ] ), { length: 2, 0: 1, 1: 2},
|
|
910
|
+
"First array like");
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
test("jQuery.extend(Object, Object)", function() {
|
|
914
|
+
expect(28);
|
|
915
|
+
|
|
916
|
+
var settings = { "xnumber1": 5, "xnumber2": 7, "xstring1": "peter", "xstring2": "pan" },
|
|
917
|
+
options = { "xnumber2": 1, "xstring2": "x", "xxx": "newstring" },
|
|
918
|
+
optionsCopy = { "xnumber2": 1, "xstring2": "x", "xxx": "newstring" },
|
|
919
|
+
merged = { "xnumber1": 5, "xnumber2": 1, "xstring1": "peter", "xstring2": "x", "xxx": "newstring" },
|
|
920
|
+
deep1 = { "foo": { "bar": true } },
|
|
921
|
+
deep1copy = { "foo": { "bar": true } },
|
|
922
|
+
deep2 = { "foo": { "baz": true }, "foo2": document },
|
|
923
|
+
deep2copy = { "foo": { "baz": true }, "foo2": document },
|
|
924
|
+
deepmerged = { "foo": { "bar": true, "baz": true }, "foo2": document },
|
|
925
|
+
arr = [1, 2, 3],
|
|
926
|
+
nestedarray = { "arr": arr };
|
|
927
|
+
|
|
928
|
+
jQuery.extend(settings, options);
|
|
929
|
+
deepEqual( settings, merged, "Check if extended: settings must be extended" );
|
|
930
|
+
deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
|
|
931
|
+
|
|
932
|
+
jQuery.extend(settings, null, options);
|
|
933
|
+
deepEqual( settings, merged, "Check if extended: settings must be extended" );
|
|
934
|
+
deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
|
|
935
|
+
|
|
936
|
+
jQuery.extend(true, deep1, deep2);
|
|
937
|
+
deepEqual( deep1["foo"], deepmerged["foo"], "Check if foo: settings must be extended" );
|
|
938
|
+
deepEqual( deep2["foo"], deep2copy["foo"], "Check if not deep2: options must not be modified" );
|
|
939
|
+
equal( deep1["foo2"], document, "Make sure that a deep clone was not attempted on the document" );
|
|
940
|
+
|
|
941
|
+
ok( jQuery.extend(true, {}, nestedarray)["arr"] !== arr, "Deep extend of object must clone child array" );
|
|
942
|
+
|
|
943
|
+
// #5991
|
|
944
|
+
ok( jQuery.isArray( jQuery.extend(true, { "arr": {} }, nestedarray)["arr"] ), "Cloned array heve to be an Array" );
|
|
945
|
+
ok( jQuery.isPlainObject( jQuery.extend(true, { "arr": arr }, { "arr": {} })["arr"] ), "Cloned object heve to be an plain object" );
|
|
946
|
+
|
|
947
|
+
var empty = {};
|
|
948
|
+
var optionsWithLength = { "foo": { "length": -1 } };
|
|
949
|
+
jQuery.extend(true, empty, optionsWithLength);
|
|
950
|
+
deepEqual( empty["foo"], optionsWithLength["foo"], "The length property must copy correctly" );
|
|
951
|
+
|
|
952
|
+
empty = {};
|
|
953
|
+
var optionsWithDate = { "foo": { "date": new Date() } };
|
|
954
|
+
jQuery.extend(true, empty, optionsWithDate);
|
|
955
|
+
deepEqual( empty["foo"], optionsWithDate["foo"], "Dates copy correctly" );
|
|
956
|
+
|
|
957
|
+
/** @constructor */
|
|
958
|
+
var myKlass = function() {};
|
|
959
|
+
var customObject = new myKlass();
|
|
960
|
+
var optionsWithCustomObject = { "foo": { "date": customObject } };
|
|
961
|
+
empty = {};
|
|
962
|
+
jQuery.extend(true, empty, optionsWithCustomObject);
|
|
963
|
+
ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly (no methods)" );
|
|
964
|
+
|
|
965
|
+
// Makes the class a little more realistic
|
|
966
|
+
myKlass.prototype = { "someMethod": function(){} };
|
|
967
|
+
empty = {};
|
|
968
|
+
jQuery.extend(true, empty, optionsWithCustomObject);
|
|
969
|
+
ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly" );
|
|
970
|
+
|
|
971
|
+
var MyNumber = Number;
|
|
972
|
+
var ret = jQuery.extend(true, { "foo": 4 }, { "foo": new MyNumber(5) } );
|
|
973
|
+
ok( ret.foo == 5, "Wrapped numbers copy correctly" );
|
|
974
|
+
|
|
975
|
+
var nullUndef;
|
|
976
|
+
nullUndef = jQuery.extend({}, options, { "xnumber2": null });
|
|
977
|
+
ok( nullUndef["xnumber2"] === null, "Check to make sure null values are copied");
|
|
978
|
+
|
|
979
|
+
nullUndef = jQuery.extend({}, options, { "xnumber2": undefined });
|
|
980
|
+
ok( nullUndef["xnumber2"] === options["xnumber2"], "Check to make sure undefined values are not copied");
|
|
981
|
+
|
|
982
|
+
nullUndef = jQuery.extend({}, options, { "xnumber0": null });
|
|
983
|
+
ok( nullUndef["xnumber0"] === null, "Check to make sure null values are inserted");
|
|
984
|
+
|
|
985
|
+
var target = {};
|
|
986
|
+
var recursive = { foo:target, bar:5 };
|
|
987
|
+
jQuery.extend(true, target, recursive);
|
|
988
|
+
deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
|
|
989
|
+
|
|
990
|
+
ret = jQuery.extend(true, { foo: [] }, { foo: [0] } ); // 1907
|
|
991
|
+
equal( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
|
|
992
|
+
|
|
993
|
+
ret = jQuery.extend(true, { foo: "1,2,3" }, { foo: [1, 2, 3] } );
|
|
994
|
+
ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
|
|
995
|
+
|
|
996
|
+
ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
|
|
997
|
+
ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" );
|
|
998
|
+
|
|
999
|
+
var obj = { foo:null };
|
|
1000
|
+
jQuery.extend(true, obj, { foo:"notnull" } );
|
|
1001
|
+
equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
|
|
1002
|
+
|
|
1003
|
+
function func() {}
|
|
1004
|
+
jQuery.extend(func, { key: "value" } );
|
|
1005
|
+
equal( func.key, "value", "Verify a function can be extended" );
|
|
1006
|
+
|
|
1007
|
+
var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
|
1008
|
+
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
|
1009
|
+
options1 = { xnumber2: 1, xstring2: "x" },
|
|
1010
|
+
options1Copy = { xnumber2: 1, xstring2: "x" },
|
|
1011
|
+
options2 = { xstring2: "xx", xxx: "newstringx" },
|
|
1012
|
+
options2Copy = { xstring2: "xx", xxx: "newstringx" },
|
|
1013
|
+
merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
|
|
1014
|
+
|
|
1015
|
+
settings = jQuery.extend({}, defaults, options1, options2);
|
|
1016
|
+
deepEqual( settings, merged2, "Check if extended: settings must be extended" );
|
|
1017
|
+
deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
|
|
1018
|
+
deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
|
|
1019
|
+
deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
test("jQuery.each(Object,Function)", function() {
|
|
1023
|
+
expect( 23 );
|
|
1024
|
+
|
|
1025
|
+
var i, label, seen, callback;
|
|
1026
|
+
|
|
1027
|
+
seen = {};
|
|
1028
|
+
jQuery.each( [ 3, 4, 5 ], function( k, v ) {
|
|
1029
|
+
seen[ k ] = v;
|
|
1030
|
+
});
|
|
1031
|
+
deepEqual( seen, { "0": 3, "1": 4, "2": 5 }, "Array iteration" );
|
|
1032
|
+
|
|
1033
|
+
seen = {};
|
|
1034
|
+
jQuery.each( { name: "name", lang: "lang" }, function( k, v ) {
|
|
1035
|
+
seen[ k ] = v;
|
|
1036
|
+
});
|
|
1037
|
+
deepEqual( seen, { name: "name", lang: "lang" }, "Object iteration" );
|
|
1038
|
+
|
|
1039
|
+
seen = [];
|
|
1040
|
+
jQuery.each( [ 1, 2, 3 ], function( k, v ) {
|
|
1041
|
+
seen.push( v );
|
|
1042
|
+
if ( k === 1 ) {
|
|
1043
|
+
return false;
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
deepEqual( seen, [ 1, 2 ] , "Broken array iteration" );
|
|
1047
|
+
|
|
1048
|
+
seen = [];
|
|
1049
|
+
jQuery.each( {"a": 1, "b": 2,"c": 3 }, function( k, v ) {
|
|
1050
|
+
seen.push( v );
|
|
1051
|
+
return false;
|
|
1052
|
+
});
|
|
1053
|
+
deepEqual( seen, [ 1 ], "Broken object iteration" );
|
|
1054
|
+
|
|
1055
|
+
seen = {
|
|
1056
|
+
Zero: function() {},
|
|
1057
|
+
One: function( a ) {},
|
|
1058
|
+
Two: function( a, b ) {}
|
|
1059
|
+
};
|
|
1060
|
+
callback = function( k, v ) {
|
|
1061
|
+
equal( k, "foo", label + "-argument function treated like object" );
|
|
1062
|
+
};
|
|
1063
|
+
for ( i in seen ) {
|
|
1064
|
+
label = i;
|
|
1065
|
+
seen[ i ].foo = "bar";
|
|
1066
|
+
jQuery.each( seen[ i ], callback );
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
seen = {
|
|
1070
|
+
"undefined": undefined,
|
|
1071
|
+
"null": null,
|
|
1072
|
+
"false": false,
|
|
1073
|
+
"true": true,
|
|
1074
|
+
"empty string": "",
|
|
1075
|
+
"nonempty string": "string",
|
|
1076
|
+
"string \"0\"": "0",
|
|
1077
|
+
"negative": -1,
|
|
1078
|
+
"excess": 1
|
|
1079
|
+
};
|
|
1080
|
+
callback = function( k, v ) {
|
|
1081
|
+
equal( k, "length", "Object with " + label + " length treated like object" );
|
|
1082
|
+
};
|
|
1083
|
+
for ( i in seen ) {
|
|
1084
|
+
label = i;
|
|
1085
|
+
jQuery.each( { length: seen[ i ] }, callback );
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
seen = {
|
|
1089
|
+
"sparse Array": Array( 4 ),
|
|
1090
|
+
"length: 1 plain object": { length: 1, "0": true },
|
|
1091
|
+
"length: 2 plain object": { length: 2, "0": true, "1": true },
|
|
1092
|
+
NodeList: document.getElementsByTagName("html")
|
|
1093
|
+
};
|
|
1094
|
+
callback = function( k, v ) {
|
|
1095
|
+
if ( seen[ label ] ) {
|
|
1096
|
+
delete seen[ label ];
|
|
1097
|
+
equal( k, "0", label + " treated like array" );
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
for ( i in seen ) {
|
|
1102
|
+
label = i;
|
|
1103
|
+
jQuery.each( seen[ i ], callback );
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
seen = false;
|
|
1107
|
+
jQuery.each( { length: 0 }, function( k, v ) {
|
|
1108
|
+
seen = true;
|
|
1109
|
+
});
|
|
1110
|
+
ok( !seen, "length: 0 plain object treated like array" );
|
|
1111
|
+
|
|
1112
|
+
seen = false;
|
|
1113
|
+
jQuery.each( document.getElementsByTagName("asdf"), function( k, v ) {
|
|
1114
|
+
seen = true;
|
|
1115
|
+
});
|
|
1116
|
+
ok( !seen, "empty NodeList treated like array" );
|
|
1117
|
+
|
|
1118
|
+
i = 0;
|
|
1119
|
+
jQuery.each( document.styleSheets, function() {
|
|
1120
|
+
i++;
|
|
1121
|
+
});
|
|
1122
|
+
equal( i, 2, "Iteration over document.styleSheets" );
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
test("jQuery.makeArray", function(){
|
|
1126
|
+
expect(15);
|
|
1127
|
+
|
|
1128
|
+
equal( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
|
|
1129
|
+
|
|
1130
|
+
equal( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
|
|
1131
|
+
|
|
1132
|
+
equal( (function(arg1, arg2){ return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
|
|
1133
|
+
|
|
1134
|
+
equal( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );
|
|
1135
|
+
|
|
1136
|
+
equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" );
|
|
1137
|
+
|
|
1138
|
+
equal( jQuery.makeArray( 0 )[0], 0 , "Pass makeArray a number" );
|
|
1139
|
+
|
|
1140
|
+
equal( jQuery.makeArray( "foo" )[0], "foo", "Pass makeArray a string" );
|
|
1141
|
+
|
|
1142
|
+
equal( jQuery.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" );
|
|
1143
|
+
|
|
1144
|
+
equal( jQuery.makeArray( document.createElement("div") )[0].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" );
|
|
1145
|
+
|
|
1146
|
+
equal( jQuery.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" );
|
|
1147
|
+
|
|
1148
|
+
ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" );
|
|
1149
|
+
|
|
1150
|
+
// function, is tricky as it has length
|
|
1151
|
+
equal( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );
|
|
1152
|
+
|
|
1153
|
+
//window, also has length
|
|
1154
|
+
equal( jQuery.makeArray(window)[0], window, "Pass makeArray the window" );
|
|
1155
|
+
|
|
1156
|
+
equal( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
|
|
1157
|
+
|
|
1158
|
+
// Some nodes inherit traits of nodelists
|
|
1159
|
+
ok( jQuery.makeArray(document.getElementById("form")).length >= 13,
|
|
1160
|
+
"Pass makeArray a form (treat as elements)" );
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
test("jQuery.inArray", function(){
|
|
1164
|
+
expect(3);
|
|
1165
|
+
|
|
1166
|
+
equal( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" );
|
|
1167
|
+
|
|
1168
|
+
equal( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" );
|
|
1169
|
+
|
|
1170
|
+
equal( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" );
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
test("jQuery.isEmptyObject", function(){
|
|
1174
|
+
expect(2);
|
|
1175
|
+
|
|
1176
|
+
equal(true, jQuery.isEmptyObject({}), "isEmptyObject on empty object literal" );
|
|
1177
|
+
equal(false, jQuery.isEmptyObject({a:1}), "isEmptyObject on non-empty object literal" );
|
|
1178
|
+
|
|
1179
|
+
// What about this ?
|
|
1180
|
+
// equal(true, jQuery.isEmptyObject(null), "isEmptyObject on null" );
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
test("jQuery.proxy", function(){
|
|
1184
|
+
expect( 9 );
|
|
1185
|
+
|
|
1186
|
+
var test = function(){ equal( this, thisObject, "Make sure that scope is set properly." ); };
|
|
1187
|
+
var thisObject = { foo: "bar", method: test };
|
|
1188
|
+
|
|
1189
|
+
// Make sure normal works
|
|
1190
|
+
test.call( thisObject );
|
|
1191
|
+
|
|
1192
|
+
// Basic scoping
|
|
1193
|
+
jQuery.proxy( test, thisObject )();
|
|
1194
|
+
|
|
1195
|
+
// Another take on it
|
|
1196
|
+
jQuery.proxy( thisObject, "method" )();
|
|
1197
|
+
|
|
1198
|
+
// Make sure it doesn't freak out
|
|
1199
|
+
equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." );
|
|
1200
|
+
|
|
1201
|
+
// Partial application
|
|
1202
|
+
var test2 = function( a ){ equal( a, "pre-applied", "Ensure arguments can be pre-applied." ); };
|
|
1203
|
+
jQuery.proxy( test2, null, "pre-applied" )();
|
|
1204
|
+
|
|
1205
|
+
// Partial application w/ normal arguments
|
|
1206
|
+
var test3 = function( a, b ){ equal( b, "normal", "Ensure arguments can be pre-applied and passed as usual." ); };
|
|
1207
|
+
jQuery.proxy( test3, null, "pre-applied" )( "normal" );
|
|
1208
|
+
|
|
1209
|
+
// Test old syntax
|
|
1210
|
+
var test4 = { "meth": function( a ){ equal( a, "boom", "Ensure old syntax works." ); } };
|
|
1211
|
+
jQuery.proxy( test4, "meth" )( "boom" );
|
|
1212
|
+
|
|
1213
|
+
// jQuery 1.9 improved currying with `this` object
|
|
1214
|
+
var fn = function() {
|
|
1215
|
+
equal( Array.prototype.join.call( arguments, "," ), "arg1,arg2,arg3", "args passed" );
|
|
1216
|
+
equal( this.foo, "bar", "this-object passed" );
|
|
1217
|
+
};
|
|
1218
|
+
var cb = jQuery.proxy( fn, null, "arg1", "arg2" );
|
|
1219
|
+
cb.call( thisObject, "arg3" );
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
test("jQuery.parseHTML", function() {
|
|
1223
|
+
expect( 17 );
|
|
1224
|
+
|
|
1225
|
+
var html, nodes;
|
|
1226
|
+
|
|
1227
|
+
equal( jQuery.parseHTML(), null, "Nothing in, null out." );
|
|
1228
|
+
equal( jQuery.parseHTML( null ), null, "Null in, null out." );
|
|
1229
|
+
equal( jQuery.parseHTML( "" ), null, "Empty string in, null out." );
|
|
1230
|
+
raises(function() {
|
|
1231
|
+
jQuery.parseHTML( "<div></div>", document.getElementById("form") );
|
|
1232
|
+
}, "Passing an element as the context raises an exception (context should be a document)");
|
|
1233
|
+
|
|
1234
|
+
nodes = jQuery.parseHTML( jQuery("body")[0].innerHTML );
|
|
1235
|
+
ok( nodes.length > 4, "Parse a large html string" );
|
|
1236
|
+
equal( jQuery.type( nodes ), "array", "parseHTML returns an array rather than a nodelist" );
|
|
1237
|
+
|
|
1238
|
+
html = "<script>undefined()</script>";
|
|
1239
|
+
equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" );
|
|
1240
|
+
equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve scripts when requested" );
|
|
1241
|
+
|
|
1242
|
+
html += "<div></div>";
|
|
1243
|
+
equal( jQuery.parseHTML( html )[0].nodeName.toLowerCase(), "div", "Preserve non-script nodes" );
|
|
1244
|
+
equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve script position");
|
|
1245
|
+
|
|
1246
|
+
equal( jQuery.parseHTML("text")[0].nodeType, 3, "Parsing text returns a text node" );
|
|
1247
|
+
equal( jQuery.parseHTML( "\t<div></div>" )[0].nodeValue, "\t", "Preserve leading whitespace" );
|
|
1248
|
+
|
|
1249
|
+
equal( jQuery.parseHTML(" <div/> ")[0].nodeType, 3, "Leading spaces are treated as text nodes (#11290)" );
|
|
1250
|
+
|
|
1251
|
+
html = jQuery.parseHTML( "<div>test div</div>" );
|
|
1252
|
+
equal( html[ 0 ].parentNode.nodeType, 11, "parentNode should be documentFragment" );
|
|
1253
|
+
equal( html[ 0 ].innerHTML, "test div", "Content should be preserved" );
|
|
1254
|
+
|
|
1255
|
+
equal( jQuery.parseHTML("<span><span>").length, 1, "Incorrect html-strings should not break anything" );
|
|
1256
|
+
equal( jQuery.parseHTML("<td><td>")[ 1 ].parentNode.nodeType, 11, "parentNode should be documentFragment" );
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
test("jQuery.parseJSON", function(){
|
|
1260
|
+
expect( 9 );
|
|
1261
|
+
|
|
1262
|
+
equal( jQuery.parseJSON( null ), null, "Actual null returns null" );
|
|
1263
|
+
equal( jQuery.isEmptyObject( jQuery.parseJSON("{}") ), true, "Empty object returns empty object" );
|
|
1264
|
+
deepEqual( jQuery.parseJSON("{\"test\":1}"), { "test": 1 }, "Plain object parses" );
|
|
1265
|
+
deepEqual( jQuery.parseJSON("\n{\"test\":1}"), { "test": 1 }, "Leading whitespaces are ignored." );
|
|
1266
|
+
raises(function() {
|
|
1267
|
+
jQuery.parseJSON();
|
|
1268
|
+
}, null, "Undefined raises an error" );
|
|
1269
|
+
raises( function() {
|
|
1270
|
+
jQuery.parseJSON( "" );
|
|
1271
|
+
}, null, "Empty string raises an error" );
|
|
1272
|
+
raises(function() {
|
|
1273
|
+
jQuery.parseJSON("''");
|
|
1274
|
+
}, null, "Single-quoted string raises an error" );
|
|
1275
|
+
raises(function() {
|
|
1276
|
+
jQuery.parseJSON("{a:1}");
|
|
1277
|
+
}, null, "Unquoted property raises an error" );
|
|
1278
|
+
raises(function() {
|
|
1279
|
+
jQuery.parseJSON("{'a':1}");
|
|
1280
|
+
}, null, "Single-quoted property raises an error" );
|
|
1281
|
+
});
|
|
1282
|
+
|
|
1283
|
+
test("jQuery.parseXML", 8, function(){
|
|
1284
|
+
var xml, tmp;
|
|
1285
|
+
try {
|
|
1286
|
+
xml = jQuery.parseXML( "<p>A <b>well-formed</b> xml string</p>" );
|
|
1287
|
+
tmp = xml.getElementsByTagName( "p" )[ 0 ];
|
|
1288
|
+
ok( !!tmp, "<p> present in document" );
|
|
1289
|
+
tmp = tmp.getElementsByTagName( "b" )[ 0 ];
|
|
1290
|
+
ok( !!tmp, "<b> present in document" );
|
|
1291
|
+
strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", "<b> text is as expected" );
|
|
1292
|
+
} catch (e) {
|
|
1293
|
+
strictEqual( e, undefined, "unexpected error" );
|
|
1294
|
+
}
|
|
1295
|
+
try {
|
|
1296
|
+
xml = jQuery.parseXML( "<p>Not a <<b>well-formed</b> xml string</p>" );
|
|
1297
|
+
ok( false, "invalid xml not detected" );
|
|
1298
|
+
} catch( e ) {
|
|
1299
|
+
strictEqual( e.message, "Invalid XML: <p>Not a <<b>well-formed</b> xml string</p>", "invalid xml detected" );
|
|
1300
|
+
}
|
|
1301
|
+
try {
|
|
1302
|
+
xml = jQuery.parseXML( "" );
|
|
1303
|
+
strictEqual( xml, null, "empty string => null document" );
|
|
1304
|
+
xml = jQuery.parseXML();
|
|
1305
|
+
strictEqual( xml, null, "undefined string => null document" );
|
|
1306
|
+
xml = jQuery.parseXML( null );
|
|
1307
|
+
strictEqual( xml, null, "null string => null document" );
|
|
1308
|
+
xml = jQuery.parseXML( true );
|
|
1309
|
+
strictEqual( xml, null, "non-string => null document" );
|
|
1310
|
+
} catch( e ) {
|
|
1311
|
+
ok( false, "empty input throws exception" );
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
test("jQuery.camelCase()", function() {
|
|
1316
|
+
|
|
1317
|
+
var tests = {
|
|
1318
|
+
"foo-bar": "fooBar",
|
|
1319
|
+
"foo-bar-baz": "fooBarBaz",
|
|
1320
|
+
"girl-u-want": "girlUWant",
|
|
1321
|
+
"the-4th-dimension": "the4thDimension",
|
|
1322
|
+
"-o-tannenbaum": "OTannenbaum",
|
|
1323
|
+
"-moz-illa": "MozIlla",
|
|
1324
|
+
"-ms-take": "msTake"
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
expect(7);
|
|
1328
|
+
|
|
1329
|
+
jQuery.each( tests, function( key, val ) {
|
|
1330
|
+
equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
|
|
1331
|
+
});
|
|
1332
|
+
});
|