Skip to content

Commit

Permalink
atoms: remove Opera support
Browse files Browse the repository at this point in the history
Removes Presto-Opera support from Selenium atoms.
  • Loading branch information
andreastt committed Feb 28, 2015
1 parent 6e3c7b3 commit 62662b6
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 171 deletions.
33 changes: 5 additions & 28 deletions javascript/atoms/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,6 @@ bot.Device.prototype.getTargetOfOptionMouseEvent_ = function(type) {
}
}

// Opera only skips mouseovers and contextmenus on single selects.
if (goog.userAgent.OPERA) {
switch (type) {
case bot.events.EventType.CONTEXTMENU:
case bot.events.EventType.MOUSEOVER:
return this.select_.multiple ? this.element_ : null;
default:
return this.element_;
}
}

// WebKit always fires on the option element of multi-selects.
// On single-selects, it either fires on the parent or not at all.
if (goog.userAgent.WEBKIT) {
Expand Down Expand Up @@ -394,9 +383,9 @@ bot.Device.prototype.clickElement = function(coord, button, opt_force,

// bot.events.fire(element, 'click') can trigger all onclick events, but may
// not follow links (FORM.action or A.href).
// TAG IE GECKO WebKit Opera
// A(href) No No Yes Yes
// FORM(action) No Yes Yes Yes
// TAG IE GECKO WebKit
// A(href) No No Yes
// FORM(action) No Yes Yes
var targetLink = null;
var targetButton = null;
if (!bot.Device.ALWAYS_FOLLOWS_LINKS_ON_CLICK_) {
Expand Down Expand Up @@ -498,15 +487,7 @@ bot.Device.prototype.focusOnElement = function() {
// Try to focus on the element.
if (goog.isFunction(elementToFocus.focus) ||
goog.userAgent.IE && goog.isObject(elementToFocus.focus)) {
// Opera fires focus events on hidden elements (e.g. that are hidden after
// mousedown in a click sequence), but as of Opera 11 the focus() command
// does not, so we fire a focus event on the hidden element explicitly.
if (goog.userAgent.OPERA && bot.userAgent.isEngineVersion(11) &&
!bot.dom.isShown(elementToFocus)) {
bot.events.fire(elementToFocus, bot.events.EventType.FOCUS);
} else {
elementToFocus.focus();
}
elementToFocus.focus();
return true;
}

Expand All @@ -521,7 +502,7 @@ bot.Device.prototype.focusOnElement = function() {
* @const
*/
bot.Device.ALWAYS_FOLLOWS_LINKS_ON_CLICK_ =
goog.userAgent.WEBKIT || goog.userAgent.OPERA ||
goog.userAgent.WEBKIT ||
(bot.userAgent.FIREFOX_EXTENSION && bot.userAgent.isProductVersion(3.6));


Expand Down Expand Up @@ -661,10 +642,6 @@ bot.Device.prototype.toggleRadioButtonOrCheckbox_ = function(wasChecked) {
return;
}
this.element_.checked = !wasChecked;
// Only Opera versions < 11 do not fire the change event themselves.
if (goog.userAgent.OPERA && !bot.userAgent.isEngineVersion(11)) {
bot.events.fire(this.element_, bot.events.EventType.CHANGE);
}
};


Expand Down
15 changes: 2 additions & 13 deletions javascript/atoms/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bot.dom.isInteractable = function(element) {
* @private
*/
bot.dom.hasPointerEventsDisabled_ = function(element) {
if (goog.userAgent.IE || goog.userAgent.OPERA ||
if (goog.userAgent.IE ||
(goog.userAgent.GECKO && !bot.userAgent.isEngineVersion('1.9.2'))) {
// Don't support pointer events
return false;
Expand Down Expand Up @@ -216,7 +216,6 @@ bot.dom.SPLIT_STYLE_ATTRIBUTE_ON_SEMICOLONS_REGEXP_ =
* Standardize a style attribute value, which includes:
* (1) converting all property names lowercase
* (2) ensuring it ends in a trailing semi-colon
* (3) removing empty style values (which only appear on Opera).
* @param {string} value The style attribute value.
* @return {string} The identical value, with the formatting rules described
* above applied.
Expand All @@ -237,7 +236,7 @@ bot.dom.standardizeStyleAttribute_ = function(value) {
});
css = css.join('');
css = css.charAt(css.length - 1) == ';' ? css : css + ';';
return goog.userAgent.OPERA ? css.replace(/\w+:;/g, '') : css;
return css;
};


Expand Down Expand Up @@ -884,16 +883,6 @@ bot.dom.getClientRect = function(elem) {
rect.top -= doc.documentElement.clientTop + doc.body.clientTop;
}

// Opera sometimes falsely report zero size bounding rects.
if (goog.userAgent.OPERA) {
if (rect.width == 0 && elem.offsetWidth > 0) {
rect.width = elem.offsetWidth;
}
if (rect.height == 0 && elem.offsetHeight > 0) {
rect.height = elem.offsetHeight;
}
}

// On Gecko < 12, getBoundingClientRect does not account for CSS transforms.
// TODO: Remove this when we drop support for FF3.6 and FF10.
if (goog.userAgent.GECKO && !bot.userAgent.isEngineVersion(12)) {
Expand Down
9 changes: 4 additions & 5 deletions javascript/atoms/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ goog.require('goog.userAgent.product');
* @type {boolean}
*/
bot.events.SUPPORTS_TOUCH_EVENTS = !(goog.userAgent.IE &&
!bot.userAgent.isEngineVersion(10)) &&
!goog.userAgent.OPERA;
!bot.userAgent.isEngineVersion(10));


/**
Expand Down Expand Up @@ -334,13 +333,13 @@ bot.events.MouseEventFactory_.prototype.create = function(target, opt_args) {
// All browser but Firefox provide the wheelDelta value in the event.
// Firefox provides the scroll amount in the detail field, where it has the
// opposite polarity of the wheelDelta (upward scroll is negative) and is a
// factor of 40 less than the wheelDelta value. Opera provides both values.
// factor of 40 less than the wheelDelta value.
// The wheelDelta value is normally some multiple of 40.
if (this == bot.events.EventType.MOUSEWHEEL) {
if (!goog.userAgent.GECKO) {
event.wheelDelta = args.wheelDelta;
}
if (goog.userAgent.GECKO || goog.userAgent.OPERA) {
if (goog.userAgent.GECKO) {
detail = args.wheelDelta / -40;
}
}
Expand Down Expand Up @@ -424,7 +423,7 @@ bot.events.KeyboardEventFactory_.prototype.create = function(target, opt_args) {
} else {
if (bot.userAgent.IE_DOC_PRE9) {
event = doc.createEventObject();
} else { // WebKit, Opera, and IE 9+ in Standards mode.
} else { // WebKit and IE 9+ in Standards mode.
event = doc.createEvent('Events');
event.initEvent(this.type_, this.bubbles_, this.cancelable_);
}
Expand Down
8 changes: 4 additions & 4 deletions javascript/atoms/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ bot.json.NATIVE_JSON = true;
* @private {boolean}
*/
bot.json.SUPPORTS_NATIVE_JSON_ =
// List WebKit and Opera first since every supported version of these
// browsers supports native JSON (and we can compile away large chunks of
// code for individual fragments by setting the appropriate compiler flags).
goog.userAgent.WEBKIT || goog.userAgent.OPERA ||
// List WebKit first since every supported version supports
// native JSON (and we can compile away large chunks of code for
// individual fragments by setting the appropriate compiler flags).
goog.userAgent.WEBKIT ||
(goog.userAgent.GECKO && bot.userAgent.isEngineVersion(3.5)) ||
(goog.userAgent.IE && bot.userAgent.isEngineVersion(8));

Expand Down
70 changes: 33 additions & 37 deletions javascript/atoms/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bot.Keyboard.CHAR_TO_KEY_ = {};
* of the new keyword, also helps reduce the size of the compiled Js fragment.
*
* @param {null|number|
* {gecko: (?number), ieWebkit: (?number), opera: (?number)}} code
* {gecko: (?number), ieWebkit: (?number)}} code
* Either a single keycode or a record of per-browser keycodes.
* @param {string=} opt_char Character when shift is not pressed.
* @param {string=} opt_shiftChar Character when shift is pressed.
Expand All @@ -102,8 +102,6 @@ bot.Keyboard.newKey_ = function(code, opt_char, opt_shiftChar) {
if (goog.isObject(code)) {
if (goog.userAgent.GECKO) {
code = code.gecko;
} else if (goog.userAgent.OPERA) {
code = code.opera;
} else { // IE and Webkit
code = code.ieWebkit;
}
Expand Down Expand Up @@ -219,41 +217,40 @@ bot.Keyboard.Keys = {

// Branded keys
META: bot.Keyboard.newKey_(
goog.userAgent.WINDOWS ? {gecko: 91, ieWebkit: 91, opera: 219} :
(goog.userAgent.MAC ? {gecko: 224, ieWebkit: 91, opera: 17} :
{gecko: 0, ieWebkit: 91, opera: null})), // Linux
goog.userAgent.WINDOWS ? {gecko: 91, ieWebkit: 91} :
(goog.userAgent.MAC ? {gecko: 224, ieWebkit: 91} :
{gecko: 0, ieWebkit: 91})), // Linux
META_RIGHT: bot.Keyboard.newKey_(
goog.userAgent.WINDOWS ? {gecko: 92, ieWebkit: 92, opera: 220} :
(goog.userAgent.MAC ? {gecko: 224, ieWebkit: 93, opera: 17} :
{gecko: 0, ieWebkit: 92, opera: null})), // Linux
goog.userAgent.WINDOWS ? {gecko: 92, ieWebkit: 92} :
(goog.userAgent.MAC ? {gecko: 224, ieWebkit: 93} :
{gecko: 0, ieWebkit: 92})), // Linux
CONTEXT_MENU: bot.Keyboard.newKey_(
goog.userAgent.WINDOWS ? {gecko: 93, ieWebkit: 93, opera: 0} :
(goog.userAgent.MAC ? {gecko: 0, ieWebkit: 0, opera: 16} :
{gecko: 93, ieWebkit: null, opera: 0})), // Linux
goog.userAgent.WINDOWS ? {gecko: 93, ieWebkit: 93} :
(goog.userAgent.MAC ? {gecko: 0, ieWebkit: 0} :
{gecko: 93, ieWebkit: null})), // Linux

// Numpad keys
NUM_ZERO: bot.Keyboard.newKey_({gecko: 96, ieWebkit: 96, opera: 48}, '0'),
NUM_ONE: bot.Keyboard.newKey_({gecko: 97, ieWebkit: 97, opera: 49}, '1'),
NUM_TWO: bot.Keyboard.newKey_({gecko: 98, ieWebkit: 98, opera: 50}, '2'),
NUM_THREE: bot.Keyboard.newKey_({gecko: 99, ieWebkit: 99, opera: 51}, '3'),
NUM_FOUR: bot.Keyboard.newKey_({gecko: 100, ieWebkit: 100, opera: 52}, '4'),
NUM_FIVE: bot.Keyboard.newKey_({gecko: 101, ieWebkit: 101, opera: 53}, '5'),
NUM_SIX: bot.Keyboard.newKey_({gecko: 102, ieWebkit: 102, opera: 54}, '6'),
NUM_SEVEN: bot.Keyboard.newKey_({gecko: 103, ieWebkit: 103, opera: 55}, '7'),
NUM_EIGHT: bot.Keyboard.newKey_({gecko: 104, ieWebkit: 104, opera: 56}, '8'),
NUM_NINE: bot.Keyboard.newKey_({gecko: 105, ieWebkit: 105, opera: 57}, '9'),
NUM_ZERO: bot.Keyboard.newKey_({gecko: 96, ieWebkit: 96}, '0'),
NUM_ONE: bot.Keyboard.newKey_({gecko: 97, ieWebkit: 97}, '1'),
NUM_TWO: bot.Keyboard.newKey_({gecko: 98, ieWebkit: 98}, '2'),
NUM_THREE: bot.Keyboard.newKey_({gecko: 99, ieWebkit: 99}, '3'),
NUM_FOUR: bot.Keyboard.newKey_({gecko: 100, ieWebkit: 100}, '4'),
NUM_FIVE: bot.Keyboard.newKey_({gecko: 101, ieWebkit: 101}, '5'),
NUM_SIX: bot.Keyboard.newKey_({gecko: 102, ieWebkit: 102}, '6'),
NUM_SEVEN: bot.Keyboard.newKey_({gecko: 103, ieWebkit: 103}, '7'),
NUM_EIGHT: bot.Keyboard.newKey_({gecko: 104, ieWebkit: 104}, '8'),
NUM_NINE: bot.Keyboard.newKey_({gecko: 105, ieWebkit: 105}, '9'),
NUM_MULTIPLY: bot.Keyboard.newKey_(
{gecko: 106, ieWebkit: 106, opera: goog.userAgent.LINUX ? 56 : 42}, '*'),
{gecko: 106, ieWebkit: 106}, '*'),
NUM_PLUS: bot.Keyboard.newKey_(
{gecko: 107, ieWebkit: 107, opera: goog.userAgent.LINUX ? 61 : 43}, '+'),
{gecko: 107, ieWebkit: 107}, '+'),
NUM_MINUS: bot.Keyboard.newKey_(
{gecko: 109, ieWebkit: 109, opera: goog.userAgent.LINUX ? 109 : 45}, '-'),
{gecko: 109, ieWebkit: 109}, '-'),
NUM_PERIOD: bot.Keyboard.newKey_(
{gecko: 110, ieWebkit: 110, opera: goog.userAgent.LINUX ? 190 : 78}, '.'),
{gecko: 110, ieWebkit: 110}, '.'),
NUM_DIVISION: bot.Keyboard.newKey_(
{gecko: 111, ieWebkit: 111, opera: goog.userAgent.LINUX ? 191 : 47}, '/'),
NUM_LOCK: bot.Keyboard.newKey_(
(goog.userAgent.LINUX && goog.userAgent.OPERA) ? null : 144),
{gecko: 111, ieWebkit: 111}, '/'),
NUM_LOCK: bot.Keyboard.newKey_(144),

// Function keys
F1: bot.Keyboard.newKey_(112),
Expand All @@ -271,10 +268,10 @@ bot.Keyboard.Keys = {

// Punctuation keys
EQUALS: bot.Keyboard.newKey_(
{gecko: 107, ieWebkit: 187, opera: 61}, '=', '+'),
{gecko: 107, ieWebkit: 187}, '=', '+'),
SEPARATOR: bot.Keyboard.newKey_(108, ','),
HYPHEN: bot.Keyboard.newKey_(
{gecko: 109, ieWebkit: 189, opera: 109}, '-', '_'),
{gecko: 109, ieWebkit: 189}, '-', '_'),
COMMA: bot.Keyboard.newKey_(188, ',', '<'),
PERIOD: bot.Keyboard.newKey_(190, '.', '>'),
SLASH: bot.Keyboard.newKey_(191, '/', '?'),
Expand All @@ -283,7 +280,7 @@ bot.Keyboard.Keys = {
BACKSLASH: bot.Keyboard.newKey_(220, '\\', '|'),
CLOSE_BRACKET: bot.Keyboard.newKey_(221, ']', '}'),
SEMICOLON: bot.Keyboard.newKey_(
{gecko: 59, ieWebkit: 186, opera: 59}, ';', ':'),
{gecko: 59, ieWebkit: 186}, ';', ':'),
APOSTROPHE: bot.Keyboard.newKey_(222, '\'', '"')
};

Expand Down Expand Up @@ -392,13 +389,12 @@ bot.Keyboard.prototype.setKeyPressed_ = function(key, isPressed) {

/**
* The value used for newlines in the current browser/OS combination. Although
* the line endings look platform dependent, they are browser dependent. In
* particular, Opera uses \r\n on all platforms.
* the line endings look platform dependent, they are browser dependent.
*
* @private {string}
* @const
*/
bot.Keyboard.NEW_LINE_ =
goog.userAgent.IE || goog.userAgent.OPERA ? '\r\n' : '\n';
bot.Keyboard.NEW_LINE_ = goog.userAgent.IE ? '\r\n' : '\n';


/**
Expand Down Expand Up @@ -465,7 +461,7 @@ bot.Keyboard.prototype.requiresKeyPress_ = function(key) {
return false;
} else if (goog.userAgent.IE) {
return key == bot.Keyboard.Keys.ESC;
} else { // Gecko and Opera
} else { // Gecko
switch (key) {
case bot.Keyboard.Keys.SHIFT:
case bot.Keyboard.Keys.CONTROL:
Expand Down
9 changes: 1 addition & 8 deletions javascript/atoms/locators/xpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ bot.locators.xpath.single = function(target, root) {

if (result) {
var node = result.singleNodeValue;
// On Opera, a singleNodeValue of undefined indicates a type error, while
// other browsers may use it to indicate something has not been found.
return goog.userAgent.OPERA ? node : (node || null);
return node || null;
} else if (root.selectSingleNode) {
var doc = goog.dom.getOwnerDocument(root);
if (doc.setProperty) {
Expand Down Expand Up @@ -226,11 +224,6 @@ bot.locators.xpath.many = function(target, root) {
bot.locators.XPathResult_.ORDERED_NODE_SNAPSHOT_TYPE);
if (result) {
var count = result.snapshotLength;
// On Opera, if the XPath evaluates to a non-Node value, snapshotLength
// will be undefined and the result empty, so fail immediately.
if (goog.userAgent.OPERA && !goog.isDef(count)) {
bot.locators.xpath.checkElement_(null, target);
}
var results = [];
for (var i = 0; i < count; ++i) {
results.push(result.snapshotItem(i));
Expand Down
2 changes: 1 addition & 1 deletion javascript/atoms/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bot.Mouse.NO_BUTTON_VALUE_INDEX_ = 3;
* dblclick mousedown mouseover
* IE_DOC_PRE9 0 0 0 X 1 4 2 X 0 0 0 0 1 4 2 0 X X 0 X
* WEBKIT/IE9 0 1 2 X 0 1 2 X 0 1 2 0 0 1 2 0 X X 2 X
* GECKO/OPERA 0 1 2 X 0 1 2 X 0 0 0 0 0 0 0 0 X X 2 X
* GECKO 0 1 2 X 0 1 2 X 0 0 0 0 0 0 0 0 X X 2 X
* </pre>
* @private {!Object.<bot.events.EventType, !Array.<?number>>}
* @const
Expand Down
7 changes: 1 addition & 6 deletions javascript/atoms/test/click_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@
expectedEvents = goog.array.slice(clickEvents, 0, i + 1);
}

// Opera fires a focus event when the element is hidden on mousedown.
if (goog.userAgent.OPERA && hideOn == goog.events.EventType.MOUSEDOWN) {
expectedEvents.push(goog.events.EventType.FOCUS);
}

// If we expect a focus event, only test if the window is focused.
if (!goog.array.contains(expectedEvents, goog.events.EventType.FOCUS) ||
bot.test.isWindowFocused()) {
Expand Down Expand Up @@ -369,7 +364,7 @@
shouldBeAbleToClickOnElementsWithOpacityZero, bot.action.tap);

function shouldNotBeAbleToClickOnElementWithPointerEventsNone(action) {
if (!checkActionCompatibility(action) || goog.userAgent.IE || goog.userAgent.OPERA ||
if (!checkActionCompatibility(action) || goog.userAgent.IE ||
(goog.userAgent.GECKO && !bot.userAgent.isEngineVersion('1.9.2'))) {
return;
}
Expand Down
Loading

0 comments on commit 62662b6

Please sign in to comment.