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
classiccms-0.7.5 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.7.4 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.7.3 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.7.2 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.7.1 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.7.0 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.9 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.8 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.7 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.6 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.5 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.4 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.3 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.2 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.1 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.6.0 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.5.17 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.5.16 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.5.15 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb
classiccms-0.5.14 vendor/bundle/gems/therubyracer-0.10.1/specmem/proxies_memspec.rb