arachni 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +159 -0
- data/LICENSE.md +126 -196
- data/README.md +32 -24
- data/arachni.gemspec +7 -7
- data/components/checks/active/code_injection_timing.rb +3 -3
- data/components/checks/active/csrf.rb +2 -2
- data/components/checks/active/file_inclusion.rb +6 -7
- data/components/checks/active/os_cmd_injection.rb +3 -3
- data/components/checks/active/path_traversal.rb +7 -7
- data/components/checks/active/response_splitting.rb +9 -4
- data/components/checks/active/session_fixation.rb +7 -3
- data/components/checks/active/source_code_disclosure.rb +5 -5
- data/components/checks/active/unvalidated_redirect.rb +12 -3
- data/components/checks/active/unvalidated_redirect_dom.rb +3 -3
- data/components/checks/active/xss.rb +23 -10
- data/components/checks/active/xss_dom_inputs.rb +113 -11
- data/components/checks/active/xxe.rb +3 -3
- data/components/checks/passive/backdoors.rb +6 -5
- data/components/checks/passive/backup_directories.rb +6 -6
- data/components/checks/passive/backup_files.rb +6 -6
- data/components/checks/passive/common_admin_interfaces.rb +58 -0
- data/components/checks/passive/common_admin_interfaces/admin-panels.txt +49 -0
- data/components/checks/passive/common_directories/directories.txt +0 -16
- data/components/checks/passive/common_files.rb +6 -5
- data/components/checks/passive/common_files/filenames.txt +0 -2
- data/components/checks/passive/directory_listing.rb +6 -6
- data/components/checks/passive/grep/cookie_set_for_parent_domain.rb +3 -3
- data/components/checks/passive/grep/hsts.rb +6 -3
- data/components/checks/passive/grep/http_only_cookies.rb +3 -3
- data/components/checks/passive/grep/insecure_cookies.rb +2 -2
- data/components/checks/passive/grep/insecure_cors_policy.rb +6 -4
- data/components/checks/passive/grep/x_frame_options.rb +6 -4
- data/components/checks/passive/htaccess_limit.rb +6 -2
- data/components/checks/passive/http_put.rb +8 -4
- data/components/checks/passive/interesting_responses.rb +3 -2
- data/components/checks/passive/localstart_asp.rb +6 -2
- data/components/checks/passive/origin_spoof_access_restriction_bypass.rb +5 -1
- data/components/checks/passive/xst.rb +6 -2
- data/components/fingerprinters/frameworks/aspx_mvc.rb +43 -0
- data/components/fingerprinters/frameworks/cakephp.rb +28 -0
- data/components/fingerprinters/frameworks/cherrypy.rb +31 -0
- data/components/fingerprinters/frameworks/django.rb +33 -0
- data/components/fingerprinters/frameworks/jsf.rb +30 -0
- data/components/fingerprinters/frameworks/rack.rb +5 -7
- data/components/fingerprinters/frameworks/rails.rb +43 -0
- data/components/fingerprinters/languages/aspx.rb +11 -11
- data/components/fingerprinters/languages/{jsp.rb → java.rb} +11 -7
- data/components/fingerprinters/languages/php.rb +6 -6
- data/components/fingerprinters/languages/python.rb +14 -6
- data/components/fingerprinters/languages/ruby.rb +3 -5
- data/components/fingerprinters/servers/apache.rb +5 -4
- data/components/fingerprinters/servers/gunicorn.rb +33 -0
- data/components/fingerprinters/servers/jetty.rb +1 -1
- data/components/fingerprinters/servers/tomcat.rb +11 -4
- data/components/path_extractors/anchors.rb +5 -12
- data/components/path_extractors/areas.rb +5 -13
- data/components/path_extractors/comments.rb +5 -3
- data/components/path_extractors/data_url.rb +21 -0
- data/components/path_extractors/forms.rb +5 -13
- data/components/path_extractors/frames.rb +6 -13
- data/components/path_extractors/generic.rb +3 -12
- data/components/path_extractors/links.rb +5 -13
- data/components/path_extractors/meta_refresh.rb +5 -13
- data/components/path_extractors/scripts.rb +8 -14
- data/components/plugins/autologin.rb +17 -5
- data/components/plugins/defaults/meta/remedies/discovery.rb +11 -29
- data/components/plugins/login_script.rb +40 -10
- data/components/plugins/metrics.rb +235 -0
- data/components/plugins/proxy.rb +21 -4
- data/components/plugins/proxy/panel/page_accordion.html.erb +34 -2
- data/components/plugins/restrict_to_dom_state.rb +70 -0
- data/components/plugins/vector_feed.rb +38 -9
- data/components/reporters/plugin_formatters/html/metrics.rb +290 -0
- data/components/reporters/plugin_formatters/stdout/metrics.rb +80 -0
- data/components/reporters/plugin_formatters/xml/metrics.rb +29 -0
- data/components/reporters/stdout.rb +4 -2
- data/components/reporters/xml.rb +4 -4
- data/components/reporters/xml/schema.xsd +95 -0
- data/lib/arachni.rb +2 -0
- data/lib/arachni/browser.rb +132 -77
- data/lib/arachni/browser/javascript.rb +173 -45
- data/lib/arachni/browser/javascript/scripts/dom_monitor.js +81 -6
- data/lib/arachni/browser/javascript/scripts/taint_tracer.js +31 -3
- data/lib/arachni/browser_cluster.rb +41 -15
- data/lib/arachni/browser_cluster/job.rb +4 -0
- data/lib/arachni/browser_cluster/jobs/resource_exploration.rb +0 -9
- data/lib/arachni/browser_cluster/worker.rb +8 -5
- data/lib/arachni/check/auditor.rb +20 -8
- data/lib/arachni/check/base.rb +38 -6
- data/lib/arachni/element/base.rb +18 -1
- data/lib/arachni/element/capabilities/analyzable/differential.rb +0 -1
- data/lib/arachni/element/capabilities/analyzable/taint.rb +40 -10
- data/lib/arachni/element/capabilities/analyzable/timeout.rb +27 -23
- data/lib/arachni/element/capabilities/auditable/dom.rb +22 -0
- data/lib/arachni/element/capabilities/inputtable.rb +6 -2
- data/lib/arachni/element/capabilities/submittable.rb +1 -1
- data/lib/arachni/element/cookie.rb +37 -23
- data/lib/arachni/element/cookie/capabilities/mutable.rb +6 -6
- data/lib/arachni/element/cookie/dom.rb +0 -8
- data/lib/arachni/element/form.rb +28 -14
- data/lib/arachni/element/form/capabilities/auditable.rb +2 -2
- data/lib/arachni/element/form/capabilities/mutable.rb +5 -5
- data/lib/arachni/element/form/dom.rb +0 -8
- data/lib/arachni/element/generic_dom.rb +1 -1
- data/lib/arachni/element/json.rb +2 -1
- data/lib/arachni/element/json/capabilities/inputtable.rb +6 -6
- data/lib/arachni/element/json/capabilities/mutable.rb +1 -1
- data/lib/arachni/element/link.rb +13 -16
- data/lib/arachni/element/link/dom.rb +1 -14
- data/lib/arachni/element/link_template.rb +3 -2
- data/lib/arachni/element/link_template/dom.rb +0 -16
- data/lib/arachni/element/server.rb +51 -9
- data/lib/arachni/element/xml.rb +1 -0
- data/lib/arachni/ethon/easy.rb +4 -1
- data/lib/arachni/framework/parts/audit.rb +26 -77
- data/lib/arachni/framework/parts/browser.rb +50 -55
- data/lib/arachni/framework/parts/check.rb +4 -3
- data/lib/arachni/framework/parts/data.rb +41 -6
- data/lib/arachni/framework/parts/state.rb +16 -7
- data/lib/arachni/http/client.rb +66 -38
- data/lib/arachni/http/client/dynamic_404_handler.rb +46 -14
- data/lib/arachni/http/headers.rb +22 -10
- data/lib/arachni/http/proxy_server.rb +67 -22
- data/lib/arachni/http/proxy_server/ssl-interceptor-cacert.pem +34 -0
- data/lib/arachni/http/proxy_server/ssl-interceptor-cakey.pem +51 -0
- data/lib/arachni/http/request.rb +71 -18
- data/lib/arachni/issue.rb +17 -3
- data/lib/arachni/option_groups/browser_cluster.rb +34 -1
- data/lib/arachni/option_groups/http.rb +1 -1
- data/lib/arachni/page.rb +26 -13
- data/lib/arachni/page/dom/transition.rb +2 -2
- data/lib/arachni/parser.rb +28 -11
- data/lib/arachni/platform/fingerprinter.rb +5 -0
- data/lib/arachni/platform/manager.rb +65 -32
- data/lib/arachni/plugin/base.rb +8 -0
- data/lib/arachni/processes/instances.rb +25 -11
- data/lib/arachni/reporter/manager.rb +2 -2
- data/lib/arachni/rpc/client/instance.rb +4 -0
- data/lib/arachni/rpc/server/framework/master.rb +3 -3
- data/lib/arachni/rpc/server/framework/multi_instance.rb +0 -8
- data/lib/arachni/rpc/server/instance.rb +2 -1
- data/lib/arachni/ruby/array.rb +5 -0
- data/lib/arachni/ruby/hash.rb +5 -0
- data/lib/arachni/ruby/string.rb +2 -3
- data/lib/arachni/session.rb +32 -6
- data/lib/arachni/state/framework.rb +6 -2
- data/lib/arachni/support/cache.rb +1 -0
- data/lib/arachni/support/cache/base.rb +12 -8
- data/lib/arachni/support/cache/least_recently_pushed.rb +29 -0
- data/lib/arachni/support/cache/least_recently_used.rb +5 -8
- data/lib/arachni/support/cache/preference.rb +1 -1
- data/lib/arachni/support/cache/random_replacement.rb +1 -25
- data/lib/arachni/support/database/queue.rb +21 -8
- data/lib/arachni/support/lookup/base.rb +7 -1
- data/lib/arachni/support/mixins/observable.rb +3 -1
- data/lib/arachni/support/profiler.rb +51 -10
- data/lib/arachni/support/signature.rb +11 -2
- data/lib/arachni/trainer.rb +8 -2
- data/lib/arachni/uri.rb +28 -25
- data/lib/arachni/uri/scope.rb +1 -1
- data/lib/arachni/utilities.rb +8 -0
- data/lib/arachni/watir/element.rb +1 -1
- data/lib/version +1 -1
- data/spec/arachni/browser/javascript/dom_monitor_spec.rb +388 -53
- data/spec/arachni/browser/javascript/taint_tracer_spec.rb +41 -0
- data/spec/arachni/browser/javascript_spec.rb +235 -61
- data/spec/arachni/browser_cluster/jobs/resource_exploration_spec.rb +0 -9
- data/spec/arachni/browser_cluster_spec.rb +58 -10
- data/spec/arachni/browser_spec.rb +170 -26
- data/spec/arachni/check/auditor_spec.rb +22 -3
- data/spec/arachni/check/base_spec.rb +84 -0
- data/spec/arachni/element/body_spec.rb +1 -1
- data/spec/arachni/element/capabilities/analyzable/taint_spec.rb +3 -3
- data/spec/arachni/element/capabilities/analyzable/timeout_spec.rb +1 -1
- data/spec/arachni/element/cookie/dom_spec.rb +0 -9
- data/spec/arachni/element/cookie_spec.rb +85 -0
- data/spec/arachni/element/form/dom_spec.rb +0 -9
- data/spec/arachni/element/form_spec.rb +46 -3
- data/spec/arachni/element/json_spec.rb +20 -0
- data/spec/arachni/element/link/dom_spec.rb +0 -9
- data/spec/arachni/element/link_spec.rb +40 -15
- data/spec/arachni/element/link_template/dom_spec.rb +0 -8
- data/spec/arachni/element/link_template_spec.rb +2 -6
- data/spec/arachni/element/server_spec.rb +94 -8
- data/spec/arachni/element/xml_spec.rb +20 -0
- data/spec/arachni/framework/parts/audit_spec.rb +12 -14
- data/spec/arachni/framework/parts/browser_spec.rb +0 -171
- data/spec/arachni/framework/parts/platform_spec.rb +14 -8
- data/spec/arachni/framework/parts/report_spec.rb +1 -1
- data/spec/arachni/framework/parts/state_spec.rb +0 -9
- data/spec/arachni/http/client/dynamic_404_handlers_spec.rb +19 -0
- data/spec/arachni/http/client_spec.rb +169 -42
- data/spec/arachni/http/headers_spec.rb +18 -0
- data/spec/arachni/http/request_spec.rb +23 -0
- data/spec/arachni/issue_spec.rb +17 -6
- data/spec/arachni/page_spec.rb +22 -2
- data/spec/arachni/parser_spec.rb +5 -0
- data/spec/arachni/platform/manager_spec.rb +57 -25
- data/spec/arachni/reporter/manager_spec.rb +26 -0
- data/spec/arachni/rpc/server/active_options_spec.rb +9 -4
- data/spec/arachni/state/framework_spec.rb +2 -8
- data/spec/arachni/support/cache/least_recently_pushed_spec.rb +90 -0
- data/spec/arachni/support/cache/least_recently_used_spec.rb +5 -13
- data/spec/arachni/support/database/queue_spec.rb +7 -0
- data/spec/arachni/support/mixins/observable_spec.rb +15 -1
- data/spec/arachni/trainer_spec.rb +2 -2
- data/spec/components/checks/active/code_injection_timing_spec.rb +1 -1
- data/spec/components/checks/active/file_inclusion_spec.rb +6 -6
- data/spec/components/checks/active/path_traversal_spec.rb +2 -2
- data/spec/components/checks/active/source_code_disclosure_spec.rb +2 -2
- data/spec/components/checks/active/unvalidated_redirect_spec.rb +6 -6
- data/spec/components/checks/active/xss_dom_inputs_spec.rb +3 -5
- data/spec/components/checks/active/xss_dom_script_context_spec.rb +1 -1
- data/spec/components/checks/active/xss_spec.rb +5 -5
- data/spec/components/checks/passive/common_admin_interfaces_spec.rb +15 -0
- data/spec/components/checks/passive/interesting_responses_spec.rb +14 -1
- data/spec/components/fingerprinters/frameworks/aspx_mvc_spec.rb +31 -0
- data/spec/components/fingerprinters/frameworks/cakephp_spec.rb +22 -0
- data/spec/components/fingerprinters/frameworks/cherrypy_spec.rb +28 -0
- data/spec/components/fingerprinters/frameworks/django_spec.rb +37 -0
- data/spec/components/fingerprinters/frameworks/jsf_spec.rb +27 -0
- data/spec/components/fingerprinters/frameworks/rack_spec.rb +11 -14
- data/spec/components/fingerprinters/frameworks/rails_spec.rb +53 -0
- data/spec/components/fingerprinters/languages/asp_spec.rb +7 -9
- data/spec/components/fingerprinters/languages/aspx_spec.rb +10 -24
- data/spec/components/fingerprinters/languages/java_spec.rb +88 -0
- data/spec/components/fingerprinters/languages/php_spec.rb +19 -12
- data/spec/components/fingerprinters/languages/python_spec.rb +22 -9
- data/spec/components/fingerprinters/languages/ruby.rb +6 -4
- data/spec/components/fingerprinters/os/bsd_spec.rb +6 -4
- data/spec/components/fingerprinters/os/linux_spec.rb +6 -4
- data/spec/components/fingerprinters/os/solaris_spec.rb +6 -4
- data/spec/components/fingerprinters/os/unix_spec.rb +6 -4
- data/spec/components/fingerprinters/os/windows_spec.rb +6 -4
- data/spec/components/fingerprinters/servers/apache_spec.rb +15 -4
- data/spec/components/fingerprinters/servers/gunicorn_spec.rb +28 -0
- data/spec/components/fingerprinters/servers/iis_spec.rb +6 -6
- data/spec/components/fingerprinters/servers/jetty_spec.rb +6 -6
- data/spec/components/fingerprinters/servers/nginx_spec.rb +6 -4
- data/spec/components/fingerprinters/servers/tomcat_spec.rb +15 -6
- data/spec/components/path_extractors/data_url_spec.rb +19 -0
- data/spec/components/plugins/autologin_spec.rb +23 -0
- data/spec/components/plugins/login_script_spec.rb +112 -24
- data/spec/components/plugins/restrict_to_dom_state_spec.rb +16 -0
- data/spec/components/plugins/vector_feed_spec.rb +39 -1
- data/spec/support/factories/page/dom.rb +9 -4
- data/spec/support/factories/page/dom/transition.rb +31 -9
- data/spec/support/factories/scan_report.rb +8 -6
- data/spec/support/fixtures/empty/placeholder +0 -0
- data/spec/support/fixtures/report.afr +0 -0
- data/spec/support/fixtures/reporters/manager_spec/error.rb +18 -0
- data/spec/support/servers/arachni/browser.rb +117 -11
- data/spec/support/servers/arachni/browser/javascript/dom_monitor.rb +148 -4
- data/spec/support/servers/arachni/check/auditor.rb +4 -0
- data/spec/support/servers/arachni/element/cookie/cookie_dom.rb +1 -1
- data/spec/support/servers/arachni/http/client.rb +5 -0
- data/spec/support/servers/arachni/http/client/dynamic_404_handler.rb +13 -0
- data/spec/support/servers/checks/active/code_injection_timing.rb +1 -1
- data/spec/support/servers/checks/active/file_inclusion.rb +2 -2
- data/spec/support/servers/checks/active/path_traversal.rb +2 -2
- data/spec/support/servers/checks/active/source_code_disclosure.rb +40 -33
- data/spec/support/servers/checks/active/trainer_check.rb +9 -10
- data/spec/support/servers/checks/active/unvalidated_redirect_dom.rb +7 -4
- data/spec/support/servers/checks/active/xss.rb +35 -0
- data/spec/support/servers/checks/active/xss_dom.rb +1 -1
- data/spec/support/servers/checks/active/xss_dom_inputs.rb +24 -0
- data/spec/support/servers/checks/active/xss_dom_script_context.rb +1 -1
- data/spec/support/servers/checks/passive/common_admin_interfaces.rb +6 -0
- data/spec/support/servers/plugins/autologin.rb +9 -0
- data/spec/support/servers/plugins/restrict_to_dom_state.rb +4 -0
- data/spec/support/shared/element/base.rb +42 -0
- data/spec/support/shared/element/capabilities/auditable.rb +4 -4
- data/spec/support/shared/element/capabilities/auditable/dom.rb +26 -0
- data/spec/support/shared/element/capabilities/inputtable.rb +16 -11
- data/spec/support/shared/element/capabilities/submitable.rb +7 -2
- data/spec/support/shared/fingerprinter.rb +8 -0
- data/spec/support/shared/path_extractor.rb +1 -1
- data/ui/cli/framework.rb +3 -3
- data/ui/cli/framework/option_parser.rb +9 -0
- data/ui/cli/output.rb +9 -0
- data/ui/cli/reporter.rb +5 -2
- data/ui/cli/utilities.rb +4 -2
- metadata +76 -17
- data/lib/arachni/http/proxy_server/ssl-interceptor-cert.pem +0 -34
- data/lib/arachni/http/proxy_server/ssl-interceptor-pkey.pem +0 -51
- data/spec/components/fingerprinters/languages/jsp_spec.rb +0 -56
@@ -14,7 +14,7 @@ class Element
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def events
|
17
|
-
(browser.execute_script( 'return arguments[0].
|
17
|
+
(browser.execute_script( 'return arguments[0]._arachni_events;', self ) || []).
|
18
18
|
map { |event, fn| [event.to_sym, fn] } |
|
19
19
|
(::Arachni::Browser::Javascript.events.flatten.map(&:to_s) & attributes).
|
20
20
|
map { |event| [event.to_sym, attribute_value( event )] }
|
data/lib/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2
|
@@ -37,10 +37,10 @@ describe Arachni::Browser::Javascript::DOMMonitor do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it 'adds
|
41
|
-
load '/elements_with_events'
|
40
|
+
it 'adds _arachni_events property to elements holding the tracked events' do
|
41
|
+
load '/elements_with_events/listeners'
|
42
42
|
|
43
|
-
javascript.run( "return document.getElementById('my-button').
|
43
|
+
javascript.run( "return document.getElementById('my-button')._arachni_events").should == [
|
44
44
|
[
|
45
45
|
'click',
|
46
46
|
'function (my_button_click) {}'
|
@@ -55,21 +55,21 @@ describe Arachni::Browser::Javascript::DOMMonitor do
|
|
55
55
|
]
|
56
56
|
]
|
57
57
|
|
58
|
-
javascript.run( "return document.getElementById('my-button2').
|
58
|
+
javascript.run( "return document.getElementById('my-button2')._arachni_events").should == [
|
59
59
|
[
|
60
60
|
'click',
|
61
61
|
'function (my_button2_click) {}'
|
62
62
|
]
|
63
63
|
]
|
64
64
|
|
65
|
-
javascript.run( "return document.getElementById('my-button3').
|
65
|
+
javascript.run( "return document.getElementById('my-button3')._arachni_events").should be_nil
|
66
66
|
end
|
67
67
|
|
68
68
|
describe '#digest' do
|
69
69
|
it 'returns a string digest of the current DOM tree' do
|
70
70
|
load '/digest'
|
71
71
|
subject.digest.should == '<HTML><HEAD><SCRIPT src=http://javascri' <<
|
72
|
-
'pt.browser.arachni/' <<'taint_tracer.js><SCRIPT
|
72
|
+
'pt.browser.arachni/' <<'taint_tracer.js><SCRIPT src' <<
|
73
73
|
'=http://javascript.browser.arachni/dom_monitor.js><SCRIPT>' <<
|
74
74
|
'<BODY onload=void();><DIV id=my-id-div><DIV class=my-class' <<
|
75
75
|
'-div><STRONG><EM><I><B><STRONG><SCRIPT><SCRIPT type=text/' <<
|
@@ -79,14 +79,14 @@ describe Arachni::Browser::Javascript::DOMMonitor do
|
|
79
79
|
it 'does not include <p> elements' do
|
80
80
|
load '/digest/p'
|
81
81
|
subject.digest.should == '<HTML><HEAD><SCRIPT src=http://javascript' <<
|
82
|
-
'.browser.arachni/taint_tracer.js><SCRIPT
|
82
|
+
'.browser.arachni/taint_tracer.js><SCRIPT src=http://' <<
|
83
83
|
'javascript.browser.arachni/dom_monitor.js><SCRIPT><BODY><STRONG>'
|
84
84
|
end
|
85
85
|
|
86
86
|
it "does not include 'data-arachni-id' attributes" do
|
87
87
|
load '/digest/data-arachni-id'
|
88
88
|
subject.digest.should == '<HTML><HEAD><SCRIPT src=http://javascript' <<
|
89
|
-
'.browser.arachni/taint_tracer.js><SCRIPT
|
89
|
+
'.browser.arachni/taint_tracer.js><SCRIPT src=http://' <<
|
90
90
|
'javascript.browser.arachni/dom_monitor.js><SCRIPT><BODY><DIV ' <<
|
91
91
|
'id=my-id-div><DIV class=my-class-div>'
|
92
92
|
end
|
@@ -143,68 +143,403 @@ describe Arachni::Browser::Javascript::DOMMonitor do
|
|
143
143
|
end
|
144
144
|
|
145
145
|
describe '#elements_with_events' do
|
146
|
-
it 'returns information about all DOM elements along with their events' do
|
147
|
-
load '/elements_with_events'
|
148
|
-
|
149
|
-
subject.elements_with_events.should == [
|
150
|
-
{ 'tag_name' => 'html', 'events' => [], 'attributes' => {}
|
151
|
-
},
|
152
|
-
{
|
153
|
-
'tag_name' => 'body', 'events' => [], 'attributes' => {}
|
154
|
-
},
|
155
|
-
{
|
156
|
-
'tag_name' => 'button',
|
157
|
-
'events' => [
|
158
|
-
['click', 'function (my_button_click) {}'],
|
159
|
-
['click', 'function (my_button_click2) {}'],
|
160
|
-
['onmouseover', 'function (my_button_onmouseover) {}']
|
161
|
-
],
|
162
|
-
'attributes' => { 'onclick' => 'handler_1()', 'id' => 'my-button' }
|
163
|
-
},
|
164
|
-
{
|
165
|
-
'tag_name' => 'button',
|
166
|
-
'events' => [
|
167
|
-
['click', 'function (my_button2_click) {}']
|
168
|
-
],
|
169
|
-
'attributes' => { 'onclick' => 'handler_2()', 'id' => 'my-button2' }
|
170
|
-
},
|
171
|
-
{
|
172
|
-
'tag_name' => 'button',
|
173
|
-
'events' => [],
|
174
|
-
'attributes' => { 'onclick' => 'handler_3()', 'id' => 'my-button3' }
|
175
|
-
}
|
176
|
-
]
|
177
|
-
end
|
178
|
-
|
179
146
|
it 'skips non visible elements' do
|
180
147
|
load '/elements_with_events/with-hidden'
|
181
148
|
|
182
149
|
subject.elements_with_events.should == [
|
183
150
|
{
|
184
|
-
|
185
|
-
|
151
|
+
'tag_name' => 'html',
|
152
|
+
'events' => [],
|
186
153
|
'attributes' => {}
|
187
154
|
},
|
188
|
-
|
189
|
-
|
190
|
-
|
155
|
+
{
|
156
|
+
'tag_name' => 'body',
|
157
|
+
'events' => [],
|
191
158
|
'attributes' => {}
|
192
159
|
},
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
160
|
+
{
|
161
|
+
'tag_name' => 'button',
|
162
|
+
'events' => [
|
163
|
+
[
|
164
|
+
'click',
|
165
|
+
'function (my_button_click) {}'
|
199
166
|
]
|
200
167
|
],
|
201
168
|
'attributes' => {
|
202
169
|
'onclick' => 'handler_1()',
|
203
|
-
|
170
|
+
'id' => 'my-button'
|
204
171
|
}
|
205
172
|
}
|
206
173
|
]
|
207
174
|
end
|
175
|
+
|
176
|
+
context 'when it has a dot delimited custom event' do
|
177
|
+
it 'retains the first part' do
|
178
|
+
load '/elements_with_events/custom-dot-delimited'
|
179
|
+
|
180
|
+
subject.elements_with_events.should == [
|
181
|
+
{
|
182
|
+
"tag_name" => "html",
|
183
|
+
"events" => [],
|
184
|
+
"attributes" => {}
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"tag_name" => "body",
|
188
|
+
"events" => [],
|
189
|
+
"attributes" => {
|
190
|
+
"style" => ""
|
191
|
+
}
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"tag_name" => "button",
|
195
|
+
"events" =>
|
196
|
+
[
|
197
|
+
[
|
198
|
+
"click",
|
199
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
200
|
+
]
|
201
|
+
],
|
202
|
+
"attributes" => {
|
203
|
+
"id" => "my-button"
|
204
|
+
}
|
205
|
+
}
|
206
|
+
]
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'when using' do
|
211
|
+
context 'event attributes' do
|
212
|
+
it 'returns information about all DOM elements along with their events' do
|
213
|
+
load '/elements_with_events/attributes'
|
214
|
+
|
215
|
+
subject.elements_with_events.should == [
|
216
|
+
{ 'tag_name' => 'html', 'events' => [], 'attributes' => {}
|
217
|
+
},
|
218
|
+
{
|
219
|
+
'tag_name' => 'body', 'events' => [], 'attributes' => {}
|
220
|
+
},
|
221
|
+
{
|
222
|
+
'tag_name' => 'button',
|
223
|
+
'events' => [],
|
224
|
+
'attributes' => { 'onclick' => 'handler_1()', 'id' => 'my-button' }
|
225
|
+
},
|
226
|
+
{
|
227
|
+
'tag_name' => 'button',
|
228
|
+
'events' => [],
|
229
|
+
'attributes' => { 'onclick' => 'handler_2()', 'id' => 'my-button2' }
|
230
|
+
},
|
231
|
+
{
|
232
|
+
'tag_name' => 'button',
|
233
|
+
'events' => [],
|
234
|
+
'attributes' => { 'onclick' => 'handler_3()', 'id' => 'my-button3' }
|
235
|
+
}
|
236
|
+
]
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context 'event listeners' do
|
241
|
+
it 'returns information about all DOM elements along with their events' do
|
242
|
+
load '/elements_with_events/listeners'
|
243
|
+
|
244
|
+
subject.elements_with_events.should == [
|
245
|
+
{ 'tag_name' => 'html', 'events' => [], 'attributes' => {}
|
246
|
+
},
|
247
|
+
{
|
248
|
+
'tag_name' => 'body', 'events' => [], 'attributes' => {}
|
249
|
+
},
|
250
|
+
{
|
251
|
+
'tag_name' => 'button',
|
252
|
+
'events' => [
|
253
|
+
['click', 'function (my_button_click) {}'],
|
254
|
+
['click', 'function (my_button_click2) {}'],
|
255
|
+
['onmouseover', 'function (my_button_onmouseover) {}']
|
256
|
+
],
|
257
|
+
'attributes' => { 'id' => 'my-button' }
|
258
|
+
},
|
259
|
+
{
|
260
|
+
'tag_name' => 'button',
|
261
|
+
'events' => [
|
262
|
+
['click', 'function (my_button2_click) {}']
|
263
|
+
],
|
264
|
+
'attributes' => { 'id' => 'my-button2' }
|
265
|
+
},
|
266
|
+
{
|
267
|
+
'tag_name' => 'button',
|
268
|
+
'events' => [],
|
269
|
+
'attributes' => { 'id' => 'my-button3' }
|
270
|
+
}
|
271
|
+
]
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'jQuery' do
|
276
|
+
describe 'on()' do
|
277
|
+
it 'returns information about all DOM elements along with their events' do
|
278
|
+
load '/elements_with_events/jQuery.on'
|
279
|
+
|
280
|
+
subject.elements_with_events.should == [
|
281
|
+
{
|
282
|
+
'tag_name' => 'html',
|
283
|
+
'events' => [],
|
284
|
+
'attributes' => {}
|
285
|
+
},
|
286
|
+
{
|
287
|
+
'tag_name' => 'body',
|
288
|
+
'events' => [],
|
289
|
+
'attributes' => {
|
290
|
+
'style' => ''
|
291
|
+
}
|
292
|
+
},
|
293
|
+
{
|
294
|
+
'tag_name' => 'button',
|
295
|
+
'events' => [
|
296
|
+
[
|
297
|
+
'click',
|
298
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
299
|
+
]
|
300
|
+
],
|
301
|
+
'attributes' => {
|
302
|
+
'id' => 'my-button'
|
303
|
+
}
|
304
|
+
}
|
305
|
+
]
|
306
|
+
end
|
307
|
+
|
308
|
+
context 'when using a selector' do
|
309
|
+
it 'assigns the events to elements that match it' do
|
310
|
+
load '/elements_with_events/jQuery.on-selector'
|
311
|
+
|
312
|
+
subject.elements_with_events.should == [
|
313
|
+
{
|
314
|
+
"tag_name" => "html",
|
315
|
+
"events" => [],
|
316
|
+
"attributes" => {}
|
317
|
+
},
|
318
|
+
{
|
319
|
+
"tag_name" => "body",
|
320
|
+
"events" =>
|
321
|
+
[
|
322
|
+
[
|
323
|
+
"click",
|
324
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
325
|
+
],
|
326
|
+
[
|
327
|
+
"hover",
|
328
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
329
|
+
]
|
330
|
+
],
|
331
|
+
"attributes" => {
|
332
|
+
"style" => "",
|
333
|
+
"id" => "body"
|
334
|
+
}
|
335
|
+
},
|
336
|
+
{
|
337
|
+
"tag_name" => "button",
|
338
|
+
"events" =>
|
339
|
+
[
|
340
|
+
[
|
341
|
+
"click",
|
342
|
+
"function () {\n\n }"
|
343
|
+
],
|
344
|
+
[
|
345
|
+
"hover",
|
346
|
+
"function () {\n\n }"
|
347
|
+
]
|
348
|
+
],
|
349
|
+
"attributes" => {
|
350
|
+
"id" => "my-button"
|
351
|
+
}
|
352
|
+
},
|
353
|
+
{
|
354
|
+
"tag_name" => "button",
|
355
|
+
"events" => [
|
356
|
+
[
|
357
|
+
"click", "function () {\n\n }"
|
358
|
+
]
|
359
|
+
],
|
360
|
+
"attributes" => {
|
361
|
+
"id" => "my-button-2"
|
362
|
+
}
|
363
|
+
}
|
364
|
+
]
|
365
|
+
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
context 'when using object types' do
|
370
|
+
it 'returns information about all DOM elements along with their events' do
|
371
|
+
load '/elements_with_events/jQuery.on-object-types'
|
372
|
+
|
373
|
+
subject.elements_with_events.should == [
|
374
|
+
{
|
375
|
+
"tag_name" => "html",
|
376
|
+
"events" => [],
|
377
|
+
"attributes" => {}
|
378
|
+
},
|
379
|
+
{
|
380
|
+
"tag_name" => "body",
|
381
|
+
"events" => [],
|
382
|
+
"attributes" => {
|
383
|
+
"style" => ""
|
384
|
+
}
|
385
|
+
},
|
386
|
+
{
|
387
|
+
"tag_name" => "button",
|
388
|
+
"events" =>
|
389
|
+
[
|
390
|
+
[
|
391
|
+
"click",
|
392
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
393
|
+
],
|
394
|
+
[
|
395
|
+
"hover",
|
396
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
397
|
+
]
|
398
|
+
],
|
399
|
+
"attributes" => {
|
400
|
+
"id" => "my-button"
|
401
|
+
}
|
402
|
+
}
|
403
|
+
]
|
404
|
+
|
405
|
+
end
|
406
|
+
|
407
|
+
context 'when using a selector' do
|
408
|
+
it 'assigns the events to elements that match it' do
|
409
|
+
load '/elements_with_events/jQuery.on-object-types-selector'
|
410
|
+
|
411
|
+
pp subject.elements_with_events.should == [
|
412
|
+
{
|
413
|
+
"tag_name" => "html",
|
414
|
+
"events" => [],
|
415
|
+
"attributes" => {}
|
416
|
+
},
|
417
|
+
{
|
418
|
+
"tag_name" => "body",
|
419
|
+
"events" => [
|
420
|
+
["click",
|
421
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
422
|
+
],
|
423
|
+
[
|
424
|
+
"hover",
|
425
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
426
|
+
]
|
427
|
+
],
|
428
|
+
"attributes" => {
|
429
|
+
"id" => "body",
|
430
|
+
"style" => ""
|
431
|
+
}
|
432
|
+
},
|
433
|
+
{
|
434
|
+
"tag_name" => "button",
|
435
|
+
"events" => [
|
436
|
+
[
|
437
|
+
"click", "function () {}"
|
438
|
+
],
|
439
|
+
[
|
440
|
+
"hover", "function () {}"
|
441
|
+
]
|
442
|
+
],
|
443
|
+
"attributes" => {
|
444
|
+
"id" => "my-button"
|
445
|
+
}
|
446
|
+
},
|
447
|
+
{
|
448
|
+
"tag_name" => "button",
|
449
|
+
"events" => [],
|
450
|
+
"attributes" => {
|
451
|
+
"id" => "my-button-2"
|
452
|
+
}
|
453
|
+
}
|
454
|
+
]
|
455
|
+
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
describe 'delegate()' do
|
462
|
+
it 'returns information about all DOM elements along with their events' do
|
463
|
+
load '/elements_with_events/jQuery.delegate'
|
464
|
+
|
465
|
+
subject.elements_with_events.should == [
|
466
|
+
{
|
467
|
+
"tag_name" => "html",
|
468
|
+
"events" => [],
|
469
|
+
"attributes" => {}
|
470
|
+
},
|
471
|
+
{
|
472
|
+
"tag_name" => "body",
|
473
|
+
"events" =>
|
474
|
+
[
|
475
|
+
[
|
476
|
+
"click",
|
477
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
478
|
+
]
|
479
|
+
],
|
480
|
+
"attributes" => {
|
481
|
+
"style" => "",
|
482
|
+
"id" => "body"
|
483
|
+
}
|
484
|
+
},
|
485
|
+
{
|
486
|
+
"tag_name" => "button",
|
487
|
+
"events" => [
|
488
|
+
[
|
489
|
+
"click",
|
490
|
+
"function () {}"
|
491
|
+
]
|
492
|
+
],
|
493
|
+
"attributes" => {
|
494
|
+
"id" => "my-button"
|
495
|
+
}
|
496
|
+
}
|
497
|
+
]
|
498
|
+
|
499
|
+
end
|
500
|
+
|
501
|
+
context 'when using object types' do
|
502
|
+
it 'returns information about all DOM elements along with their events' do
|
503
|
+
load '/elements_with_events/jQuery.delegate'
|
504
|
+
|
505
|
+
subject.elements_with_events.should == [
|
506
|
+
{
|
507
|
+
"tag_name" => "html",
|
508
|
+
"events" => [],
|
509
|
+
"attributes" => {}
|
510
|
+
},
|
511
|
+
{
|
512
|
+
"tag_name" => "body",
|
513
|
+
"events" =>
|
514
|
+
[
|
515
|
+
[
|
516
|
+
"click",
|
517
|
+
"function (e) {\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?\n\t\t\t\t\tjQuery.event.dispatch.apply( eventHandle.elem, arguments ) :\n\t\t\t\t\tundefined;\n\t\t\t}"
|
518
|
+
]
|
519
|
+
],
|
520
|
+
"attributes" => {
|
521
|
+
"id" => "body",
|
522
|
+
"style" => ""
|
523
|
+
}
|
524
|
+
},
|
525
|
+
{
|
526
|
+
"tag_name" => "button",
|
527
|
+
"events" => [
|
528
|
+
[
|
529
|
+
"click",
|
530
|
+
"function () {}"
|
531
|
+
]
|
532
|
+
],
|
533
|
+
"attributes" => {
|
534
|
+
"id" => "my-button"
|
535
|
+
}
|
536
|
+
}
|
537
|
+
]
|
538
|
+
end
|
539
|
+
end
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
208
543
|
end
|
209
544
|
|
210
545
|
end
|