Skip to content

Commit ef5d089

Browse files
committed
Define constants with common Firefox profile preferences
1 parent 07ab9b5 commit ef5d089

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

lib/Firefox/FirefoxPreferences.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
// Copyright 2004-present Facebook. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
namespace Facebook\WebDriver\Firefox;
17+
18+
/**
19+
* Constants of common Firefox profile preferences (about:config values).
20+
* @see http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries
21+
*/
22+
class FirefoxPreferences {
23+
/** @var string Port WebDriver uses to communicate with Firefox instance */
24+
const WEBDRIVER_FIREFOX_PORT = 'webdriver_firefox_port';
25+
/** @var string Should the reader view (FF 38+) be enabled? */
26+
const READER_PARSE_ON_LOAD_ENABLED = 'reader.parse-on-load.enabled';
27+
/** @var string Browser homepage */
28+
const BROWSER_STARTUP_HOMEPAGE = 'browser.startup.homepage';
29+
30+
private function __construct()
31+
{
32+
}
33+
}

lib/Firefox/FirefoxProfile.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ public function setPreference($key, $value) {
9999
return $this;
100100
}
101101

102+
/**
103+
* @param $key
104+
* @return mixed
105+
*/
106+
public function getPreference($key)
107+
{
108+
if (array_key_exists($key, $this->preferences)) {
109+
return $this->preferences[$key];
110+
}
111+
112+
return null;
113+
}
114+
102115
/**
103116
* @return string
104117
*/

lib/Remote/DesiredCapabilities.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Exception;
1919
use Facebook\WebDriver\Chrome\ChromeOptions;
2020
use Facebook\WebDriver\Firefox\FirefoxDriver;
21+
use Facebook\WebDriver\Firefox\FirefoxPreferences;
2122
use Facebook\WebDriver\Firefox\FirefoxProfile;
2223
use Facebook\WebDriver\WebDriverCapabilities;
2324
use Facebook\WebDriver\WebDriverPlatform;
@@ -203,7 +204,7 @@ public static function firefox() {
203204

204205
// disable the "Reader View" help tooltip, which can hide elements in the window.document
205206
$profile = new FirefoxProfile();
206-
$profile->setPreference('reader.parse-on-load.enabled', false);
207+
$profile->setPreference(FirefoxPreferences::READER_PARSE_ON_LOAD_ENABLED, false);
207208
$caps->setCapability(FirefoxDriver::PROFILE, $profile);
208209

209210
return $caps;

0 commit comments

Comments
 (0)