Last active
August 29, 2015 14:04
-
-
Save dparnell/dde5f9ae5345634f0a9e to your computer and use it in GitHub Desktop.
Crash V8 if you leave it running long enough
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'bundler/setup' | |
require 'v8' | |
require 'time' | |
module Crash | |
module Triggers | |
class Console | |
def info(msg) | |
Crash::Triggers.add_action({ :action => :log, :level => :info, :value => msg }) | |
print "\r[JSTrigger] [\033[32mINFO \033[m] #{msg} " | |
end | |
end | |
class JSRoot | |
def console | |
@console ||= Console.new | |
end | |
end | |
def self.reset | |
@actions = [] | |
end | |
def self.add_action(a) | |
reset if @actions.nil? | |
@actions << a | |
end | |
def self.actions | |
@actions | |
end | |
def self.test | |
if @context.nil? | |
puts "Creating new v8 context" | |
@context = V8::Context.new({ :with => JSRoot.new }) | |
end | |
Crash::Triggers.reset | |
@context.eval "console.info('#{Time.now.inspect}')" | |
end | |
end | |
end | |
puts "Starting test at #{Time.now.inspect}" | |
while true | |
Crash::Triggers.test | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'therubyracer' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment