|
| 1 | +# encoding: utf-8 |
| 2 | +# |
| 3 | +# Licensed to the Software Freedom Conservancy (SFC) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The SFC licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | + |
| 20 | +module Selenium |
| 21 | + module WebDriver |
| 22 | + module Firefox |
| 23 | + module Marionette |
| 24 | + module Bridge |
| 25 | + |
| 26 | + COMMANDS = { |
| 27 | + install_addon: [:post, 'session/:session_id/moz/addon/install'.freeze], |
| 28 | + uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall'.freeze] |
| 29 | + }.freeze |
| 30 | + |
| 31 | + def commands(command) |
| 32 | + COMMANDS[command] || super |
| 33 | + end |
| 34 | + |
| 35 | + def install_addon(path, temporary) |
| 36 | + payload = {path: path} |
| 37 | + payload.merge!(temporary: temporary) unless temporary.nil? |
| 38 | + execute :install_addon, {}, payload |
| 39 | + end |
| 40 | + |
| 41 | + def uninstall_addon(id) |
| 42 | + execute :uninstall_addon, {}, {id: id} |
| 43 | + end |
| 44 | + |
| 45 | + end # Bridge |
| 46 | + end # Marionette |
| 47 | + end # Firefox |
| 48 | + end # WebDriver |
| 49 | +end # Selenium |
0 commit comments