Skip to content

Commit

Permalink
Drop various PhantomJS hacks
Browse files Browse the repository at this point in the history
Closes #8275
  • Loading branch information
martinpitt authored and larskarlitski committed Dec 18, 2017
1 parent 3a84866 commit 761a17b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 95 deletions.
2 changes: 1 addition & 1 deletion pkg/machines/helpers.es6
Expand Up @@ -213,7 +213,7 @@ export function fileDownload ({ data, fileName = 'myFile.dat', mimeType = 'appli
window.setTimeout(() => document.body.removeChild(f), 333);
}

window.setTimeout(() => { // give phantomJS time ...
window.setTimeout(() => { // give test browser some time ...
logDebug('removing temporary A.HREF for filedownload');
document.body.removeChild(a);
}, 5000);
Expand Down
23 changes: 0 additions & 23 deletions pkg/machines/reducers.es6
Expand Up @@ -45,29 +45,6 @@ if (!Array.prototype.findIndex) {
};
}

// --- compatibility hack for PhantomJS
if (typeof Object.assign != 'function') {
Object.assign = function (target) {
'use strict';
if (target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}

target = Object(target);
for (var index = 1; index < arguments.length; index++) {
var source = arguments[index];
if (source !== null) {
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
}
return target;
};
}

// --- helpers -------------------
function getFirstIndexOfVm(state, field, value, connectionName) {
return state.findIndex(e => {
Expand Down
45 changes: 0 additions & 45 deletions pkg/ovirt/components/ClusterVms.jsx
Expand Up @@ -187,51 +187,6 @@ const ClusterVms = ({ dispatch, config }) => {
</div>);
};

// --- hack for phantomJS:
// https://tc39.github.io/ecma262/#sec-array.prototype.find
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function(predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
}

var o = Object(this);

// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;

// 3. If IsCallable(predicate) is false, throw a TypeError exception.
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}

// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
var thisArg = arguments[1];

// 5. Let k be 0.
var k = 0;

// 6. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk).
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
// d. If testResult is true, return kValue.
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
}
// e. Increase k by 1.
k++;
}

// 7. Return undefined.
return undefined;
}
});
}
// ------------

export { VmLastMessage, VmDescription, VmMemory, VmCpu, VmOS, VmHA, VmStateless };
Expand Down
5 changes: 1 addition & 4 deletions pkg/packagekit/autoupdates.jsx
Expand Up @@ -279,10 +279,7 @@ export default class AutoUpdates extends React.Component {
var autoConfig;

if (backend.enabled) {
// Array.from(Array(24).keys()) or [...Array(24).keys()] is not understood by PhantomJS
let hours = [];
for (let i = 0; i < 24; ++i)
hours.push(i);
let hours = Array.from(Array(24).keys());

autoConfig = (
<table className="auto-conf">
Expand Down
16 changes: 7 additions & 9 deletions pkg/shell/base_index.js
Expand Up @@ -509,15 +509,13 @@
}
});

if (window.navigator.userAgent.indexOf("PhantomJS") == -1) {
var old_onerror = window.onerror;
window.onerror = function cockpit_error_handler(msg, url, line) {
self.show_oops();
if (old_onerror)
return old_onerror(msg, url, line);
return false;
};
}
var old_onerror = window.onerror;
window.onerror = function cockpit_error_handler(msg, url, line) {
self.show_oops();
if (old_onerror)
return old_onerror(msg, url, line);
return false;
};

/*
* Navigation is driven by state objects, which are used with pushState()
Expand Down
1 change: 0 additions & 1 deletion pkg/shell/shell.less
Expand Up @@ -396,7 +396,6 @@ html.index-page body {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-flex; /* Fallback for PhantomJS */
display: flex;
align-items: center;
text-decoration: none;
Expand Down
1 change: 0 additions & 1 deletion pkg/shell/switcher.less
Expand Up @@ -177,7 +177,6 @@
-webkit-flex: auto;
flex: auto;
position: relative;
width: 100%; // Hack for PhantomJS

/* Position as absolute to make things work on old Chrome versions,
mainly to make tests pass */
Expand Down
18 changes: 7 additions & 11 deletions src/base1/cockpit.js
Expand Up @@ -4524,17 +4524,13 @@ function factory() {
window.parent.postMessage("\n{ \"command\": \"oops\" }", transport_origin);
};

var old_onerror;

if (window.navigator.userAgent.indexOf("PhantomJS") == -1) {
old_onerror = window.onerror;
window.onerror = function(msg, url, line) {
cockpit.oops();
if (old_onerror)
return old_onerror(msg, url, line);
return false;
};
}
var old_onerror = window.onerror;
window.onerror = function(msg, url, line) {
cockpit.oops();
if (old_onerror)
return old_onerror(msg, url, line);
return false;
};

return cockpit;
} /* scope end */
Expand Down

0 comments on commit 761a17b

Please sign in to comment.