Sha256: 8b9399d7f668021c7efbfaf3a4154d42794ab278266cf0ff446da95892068590

Contents?: true

Size: 1.41 KB

Versions: 70

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe V8::Portal::Proxies do
  include V8::MemSpec
  
  context "A Ruby object embedded into JavaScript" do
    it "holds a hard reference to any ruby object which is linked to a javascript proxy" do
      subject.register_javascript_proxy c::Object::New(), :for => Object.new
      ruby_gc do
        subject.should_not be_empty
      end
    end

    it "releases the hard reference if its corresponding javascript object has been garbage collected" do
      ruby_gc do
        rb_object = Object.new
        js_proxy = c::Object::New()
        subject.should be_empty
        subject.register_javascript_proxy js_proxy, :for => rb_object
        rb_object = nil
        subject.should_not be_empty
        v8_gc()
      end
      subject.should be_empty
    end
  end

  context "A JavaScript object embedded into Ruby" do
    it "holds a hard reference to any JavaScript object which is linked to a Ruby proxy" do
      proxy = Object.new
      subject.register_ruby_proxy proxy, :for => c::Object::New()
      ruby_gc do
        subject.should_not be_empty
      end
    end

    it "clears any strong references to the JavaScript object when it's Ruby proxy is garbage collected" do
      subject.register_ruby_proxy Object.new, :for => c::Object::New()
      subject.should_not be_empty
      ruby_gc do
        v8_gc
        GC.start
        v8_gc
      end
      subject.should be_empty
    end
  end

end

Version data entries

70 entries across 70 versions & 5 rubygems

Version Path
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.8 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
therubyracer-freebsd-0.10.1 specmem/proxies_memspec.rb
classiccms-0.3.7 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.6 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.5 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.4 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.3 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.2 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.3.1 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
horseman-0.0.5 vendor/ruby/1.9.1/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
therubyracer-0.10.1 specmem/proxies_memspec.rb
therubyracer-0.10.0 specmem/proxies_memspec.rb
therubyracer-0.9.10 specmem/proxies_memspec.rb
therubyracer-0.9.9 specmem/proxies_memspec.rb
therubyracer-0.9.8 specmem/proxies_memspec.rb
therubyracer-0.10.0beta1 specmem/proxies_memspec.rb
therubyracer-0.9.7 specmem/proxies_memspec.rb