Path: blob/trunk/rb/lib/selenium/webdriver/common/shadow_root.rb
1865 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819module Selenium20module WebDriver21class ShadowRoot22ROOT_KEY = 'shadow-6066-11e4-a52e-4f735466cecf'2324include SearchContext2526#27# Creates a new shadow root28#29# @api private30#3132def initialize(bridge, id)33@bridge = bridge34@id = id35end3637def inspect38format '#<%<class>s:0x%<hash>x id=%<id>s>', class: self.class, hash: hash * 2, id: @id.inspect39end4041def ==(other)42other.is_a?(self.class) && ref == other.ref43end44alias eql? ==4546def hash47[@id, @bridge].hash48end4950#51# @api private52# @see SearchContext53#5455def ref56[:shadow_root, @id]57end5859#60# Convert to a ShadowRoot JSON Object for transmission over the wire.61# @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#basic-terms-and-concepts62#63# @api private64#6566def to_json(*)67JSON.generate as_json68end6970#71# For Rails 3 - http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/72#73# @api private74#7576def as_json(*)77{ROOT_KEY => @id}78end7980private8182attr_reader :bridge83end # ShadowRoot84end # WebDriver85end # Selenium868788