Sha256: 51a04cc71fb7efe6546a0a1f05f600690059bd71c60d7e6e33b54710456a5e4d

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

=begin
    Copyright 2010-2015 Tasos Laskos <tasos.laskos@arachni-scanner.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

module Arachni::Element
class DOM
module Capabilities

# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
module Submittable
    include Arachni::Element::Capabilities::Submittable

    # @param  [Hash]  options
    # @param  [Block]  block
    #   Callback to be passed the evaluated {Page}.
    def submit( options = {}, &block )
        with_browser do |browser|
            prepare_browser( browser, options )

            # If we've wondered to an out-of-scope resource don't bother calling.
            # Can be caused by a JS redirect or something akin to that.
            if (transitions = self.trigger)
                page = browser.to_page
                page.dom.transitions += transitions
                block.call page.tap { |p| p.request.performer = self }
            end

            @element = nil
            @browser = nil
        end
        nil
    end

    private

    def prepare_browser( browser, options )
        @browser = browser
        browser.javascript.custom_code = options[:custom_code]
        browser.javascript.taint       = options[:taint]

        browser.load page
    end

end

end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arachni-1.3.2 lib/arachni/element/dom/capabilities/submittable.rb
arachni-1.3.1 lib/arachni/element/dom/capabilities/submittable.rb
arachni-1.3 lib/arachni/element/dom/capabilities/submittable.rb