<commit_before>BROWSER_ENGINE = `/MSIE|WebKit|Presto|Gecko/.exec(navigator.userAgent)[0]`.downcase rescue :unknown

module Browser
  # @private
  @support = `{}`

  def self.supports?(base, *extra)
    key = `base+extra`

    if defined?(`#@support[#{key}]`)
      return `#@support[#{key}]`
    end

    support = case base
      when :MutationObserver
        defined?(`window.MutationObserver`)

      when :WebSocket
        defined?(`window.WebSocket`)

      when :EventSource
        defined?(`window.EventSource`)

      when :XHR
        defined?(`window.XMLHttpRequest`)

      when :ActiveX
        defined?(`window.ActiveXObject`)

      when :query
        case extra.shift
        when :xpath
          defined?(`document.evaluate`)

        when :css
          defined?(`Element.prototype.querySelectorAll`)
        end

      when :localStorage
        defined?(`window.localStorage`)

      when :globalStorage
        defined?(`window.globalStorage`)

      when :sessionStorage
        defined?(`window.sessionStorage`)

      when :userData
        defined?(`document.body.addBehavior`)

      when :setImmediate
        case extra.shift
        when nil
          defined?(`window.setImmediate`)

        when :ie
          defined?(`window.msSetImmediate`)

        when :firefox, :mozilla, :gecko
          defined?(`window.mozSetImmediate`)

        when :opera
          defined?(`window.oSetImmediate`)

        when :chrome, :safari, :android, :webkit
          defined?(`window.webkitSetImmediate`)
        end

      when :getComputedStyle
        defined?(`window.getComputedStyle`)

      when :currentStyle
        defined?(`document.documentElement.currentStyle`)

      when :postMessage
        if defined?(`window.postMessage`) && !defined?(`window.importScripts`)
          %x{
            var ok  = true,
                old = window.onmessage;

            window.onmessage = function() { ok = false; };
            window.postMessage("", "*")
            window.onmessage = old;
          }

          `ok`
        end

      when :readystatechange
        `"onreadystatechange" in window.document.createElement("script")`

      when :window
        case extra.shift
        when :innerHeight
          defined?(`window.innerHeight`)

        when :innerWidth
          defined?(`window.innerWidth`)

        when :scrollLeft
          defined?(`document.documentElement.scrollLeft`)

        when :scrollTop
          defined?(`document.documentElement.scrollTop`)

        when :pageXOffset
          defined?(`window.pageXOffset`)

        when :pageYOffset
          defined?(`window.pageYOffset`)
        end

      when :event
        case extra.shift
        when :constructor
          begin
            `new MouseEvent("click")`

            true
          rescue
            false
          end

        when :create
          defined?(`document.createEvent`)

        when :createObject
          defined?(`document.createEventObject`)

        when :addListener
          defined?(`window.addEventListener`)

        when :attach
          defined?(`window.attachEvent`)

        when :removeListener
          defined?(`window.removeEventListener`)

        when :detach
          defined?(`window.detachEvent`)

        when :dispatch
          defined?(`window.dispatchEvent`)

        when :fire
          defined?(`window.fireEvent`)
        end

      when :document
        case extra.shift
        when :defaultView
          defined?(`document.defaultView`)

        when :parentWindow
          defined?(`document.parentWindow`)
        end

      when :element
        case extra.shift
        when :clientHeight
          defined?(`document.documentElement.clientHeight`)
<commit_msg>support: IE8- doesn't have window events<commit_after>BROWSER_ENGINE = `/MSIE|WebKit|Presto|Gecko/.exec(navigator.userAgent)[0]`.downcase rescue :unknown

module Browser
  # @private
  @support = `{}`

  def self.supports?(base, *extra)
    key = `base+extra`

    if defined?(`#@support[#{key}]`)
      return `#@support[#{key}]`
    end

    support = case base
      when :MutationObserver
        defined?(`window.MutationObserver`)

      when :WebSocket
        defined?(`window.WebSocket`)

      when :EventSource
        defined?(`window.EventSource`)

      when :XHR
        defined?(`window.XMLHttpRequest`)

      when :ActiveX
        defined?(`window.ActiveXObject`)

      when :query
        case extra.shift
        when :xpath
          defined?(`document.evaluate`)

        when :css
          defined?(`Element.prototype.querySelectorAll`)
        end

      when :localStorage
        defined?(`window.localStorage`)

      when :globalStorage
        defined?(`window.globalStorage`)

      when :sessionStorage
        defined?(`window.sessionStorage`)

      when :userData
        defined?(`document.body.addBehavior`)

      when :setImmediate
        case extra.shift
        when nil
          defined?(`window.setImmediate`)

        when :ie
          defined?(`window.msSetImmediate`)

        when :firefox, :mozilla, :gecko
          defined?(`window.mozSetImmediate`)

        when :opera
          defined?(`window.oSetImmediate`)

        when :chrome, :safari, :android, :webkit
          defined?(`window.webkitSetImmediate`)
        end

      when :getComputedStyle
        defined?(`window.getComputedStyle`)

      when :currentStyle
        defined?(`document.documentElement.currentStyle`)

      when :postMessage
        if defined?(`window.postMessage`) && !defined?(`window.importScripts`)
          %x{
            var ok  = true,
                old = window.onmessage;

            window.onmessage = function() { ok = false; };
            window.postMessage("", "*")
            window.onmessage = old;
          }

          `ok`
        end

      when :readystatechange
        `"onreadystatechange" in window.document.createElement("script")`

      when :window
        case extra.shift
        when :innerHeight
          defined?(`window.innerHeight`)

        when :innerWidth
          defined?(`window.innerWidth`)

        when :scrollLeft
          defined?(`document.documentElement.scrollLeft`)

        when :scrollTop
          defined?(`document.documentElement.scrollTop`)

        when :pageXOffset
          defined?(`window.pageXOffset`)

        when :pageYOffset
          defined?(`window.pageYOffset`)
        end

      when :event
        case extra.shift
        when :constructor
          begin
            `new MouseEvent("click")`

            true
          rescue
            false
          end

        when :create
          defined?(`document.createEvent`)

        when :createObject
          defined?(`document.createEventObject`)

        when :addListener
          defined?(`document.documentElement.addEventListener`)

        when :attach
          defined?(`document.documentElement.attachEvent`)

        when :removeListener
          defined?(`document.documentElement.removeEventListener`)

        when :detach
          defined?(`document.documentElement.detachEvent`)

        when :dispatch
          defined?(`document.documentElement.dispatchEvent`)

        when :fire
          defined?(`document.documentElement.fireEvent`)
        end

      when :document
        case extra.shift
        when :defaultView
          defined?(`document.defaultView`)

        when :parentWindow
          defined?(`document.parentWindow`)
        end

      when :element
        case extra.shift
        when :clientHeight
          defined?(`document.documentElement.clientHeight`)

{'fraction_non_alphanumeric': 0.10493908030918381, 'fraction_numerical': 0.0003930302633302764, 'mean_word_length': 2.018584420719652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6683234', 'n_tokens_mistral': 2063, 'n_tokens_neox': 1959, 'n_words': 393}