Skip to content

Commit

Permalink
@W-5773939@ Upgrade Locker to v0.6.21 + Fix Test Failures from Firefo…
Browse files Browse the repository at this point in the history
…x and Safari Enablement (#4151)
  • Loading branch information
tlau88 authored and GitHub Enterprise committed Jan 22, 2019
1 parent 7a318c4 commit 1f39aec
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@
delete div.expando;
testUtils.fail("Expected error trying to delete non-configurable property");
} catch (e) {
if ($A.get("$Browser.isFIREFOX")) {
testUtils.assertEquals("property \"expando\" is non-configurable and can't be deleted", e.message);
} else {
testUtils.assertEquals("Cannot delete property 'expando' of [object Object]", e.message);
}
// TypeError: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_delete
testUtils.assertTrue(e instanceof TypeError);
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
},

testArrayProperties: {
// SAFARI BUG: For... In... Array includes the "length" property.
browsers: ["-IE8", "-IE9", "-IE10", "-IE11", "-SAFARI", "-IPHONE", "-IPAD"],
test:function(cmp) {
cmp.testArrayProperties();
}
Expand Down Expand Up @@ -74,6 +76,8 @@
}
},
testArrayForIn : {
// SAFARI BUG: For... In... Array includes the "length" property.
browsers: ["-IE8", "-IE9", "-IE10", "-IE11", "-SAFARI", "-IPHONE", "-IPAD"],
test: function(cmp) {
cmp.testArrayForIn();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*
* Bundle from LockerService-Core
* Generated: 2019-01-15
* Version: 0.6.20
* Generated: 2019-01-21
* Version: 0.6.21
*/

(function (exports) {
Expand Down Expand Up @@ -197,6 +197,7 @@ var htmlTags = Object.keys(htmlTagsMap);
// ATTRIBUTES
var attrs = ['aria-activedescendant', 'aria-atomic', 'aria-autocomplete', 'aria-busy', 'aria-checked', 'aria-controls', 'aria-describedby', 'aria-disabled', 'aria-readonly', 'aria-dropeffect', 'aria-expanded', 'aria-flowto', 'aria-grabbed', 'aria-haspopup', 'aria-hidden', 'aria-disabled', 'aria-invalid', 'aria-label', 'aria-labelledby', 'aria-level', 'aria-live', 'aria-multiline', 'aria-multiselectable', 'aria-orientation', 'aria-owns', 'aria-posinset', 'aria-pressed', 'aria-readonly', 'aria-relevant', 'aria-required', 'aria-selected', 'aria-setsize', 'aria-sort', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'role', 'target'];

var queue = new Set();
// use a floating element for attribute sanitization
var floating$1 = document.createElement('a');

Expand All @@ -217,23 +218,53 @@ function sanitizeHrefAttribute(str) {
floating$1.href = str;
var urlParam = floating$1.href.split('#');
var url = ('' + urlParam[0]).replace(/[\\/,\\:]/g, '');
if (!document.getElementById(url)) {
var container = document.createElement('div');
var internalId = url + '_' + urlParam[1];

var container = document.getElementById(url);
if (!container) {
container = document.createElement('div');
container.setAttribute('style', 'display:none');
container.setAttribute('id', url);
document.body.appendChild(container);

queue.add(url);
var xhr = new XMLHttpRequest();
xhr.open('GET', urlParam[0]);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
container.innerHTML = sanitizeSvgText(xhr.responseText);
var content = sanitizeSvgText(xhr.responseText);
if (urlParam[1]) {
content = content.replace('"' + urlParam[1] + '"', '"' + internalId + '"');
}
container.innerHTML = content;
queue.delete(url);
}
};
xhr.send();
} else if (container && internalId) {
var updater = function updater() {
// if we use the same href multiple times we should check we parsed the ids
var el = container.querySelector('#' + internalId);
if (!el && container.innerHTML) {
var content = container.innerHTML.replace('"' + urlParam[1] + '"', '"' + internalId + '"');
container.innerHTML = content;
}
};

if (queue.has(url)) {
// wait for request to finish, then update content
var interval = setInterval(function () {
if (!queue.has(url)) {
updater();
clearInterval(interval);
}
}, 50);
} else {
updater();
}
}

return urlParam[1] ? '#' + urlParam[1] : '#' + url;
return urlParam[1] ? '#' + internalId : '#' + url;
}

function uponSanitizeAttribute(node, data) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*
* Bundle from LockerService-Core
* Generated: 2019-01-15
* Version: 0.6.20
* Generated: 2019-01-21
* Version: 0.6.21
*/

(function (exports) {
Expand Down Expand Up @@ -384,6 +384,7 @@ const attrs = [
'target'
];

const queue = new Set();
// use a floating element for attribute sanitization
const floating$1 = document.createElement('a');

Expand All @@ -404,23 +405,53 @@ function sanitizeHrefAttribute(str) {
floating$1.href = str;
const urlParam = floating$1.href.split('#');
const url = `${urlParam[0]}`.replace(/[\\/,\\:]/g, '');
if (!document.getElementById(url)) {
const container = document.createElement('div');
const internalId = `${url}_${urlParam[1]}`;

let container = document.getElementById(url);
if (!container) {
container = document.createElement('div');
container.setAttribute('style', 'display:none');
container.setAttribute('id', url);
document.body.appendChild(container);

queue.add(url);
const xhr = new XMLHttpRequest();
xhr.open('GET', urlParam[0]);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
container.innerHTML = sanitizeSvgText(xhr.responseText);
let content = sanitizeSvgText(xhr.responseText);
if (urlParam[1]) {
content = content.replace(`"${urlParam[1]}"`, `"${internalId}"`);
}
container.innerHTML = content;
queue.delete(url);
}
};
xhr.send();
} else if (container && internalId) {
const updater = () => {
// if we use the same href multiple times we should check we parsed the ids
const el = container.querySelector(`#${internalId}`);
if (!el && container.innerHTML) {
const content = container.innerHTML.replace(`"${urlParam[1]}"`, `"${internalId}"`);
container.innerHTML = content;
}
};

if (queue.has(url)) {
// wait for request to finish, then update content
const interval = setInterval(() => {
if (!queue.has(url)) {
updater();
clearInterval(interval);
}
}, 50);
} else {
updater();
}
}

return urlParam[1] ? `#${urlParam[1]}` : `#${url}`;
return urlParam[1] ? `#${internalId}` : `#${url}`;
}

function uponSanitizeAttribute(node, data) {
Expand Down Expand Up @@ -741,6 +772,15 @@ function isValidURLScheme(url) {
return normalized.protocol === 'https:' || normalized.protocol === 'http:';
}

function isWindowLikeObject(obj) {
return (
!!obj &&
typeof obj === 'object' &&
typeof obj['Window'] === 'function' &&
obj instanceof obj['Window']
);
}

function isCustomElement(el) {
return el.tagName && el.tagName.indexOf('-') > 0;
}
Expand Down Expand Up @@ -5712,6 +5752,9 @@ class SecureNodeListProxyHandler {
property = convertSymbol(property);
if (Number.isNaN(Number(property))) {
switch (property) {
case 'hasOwnProperty':
return prop => filter(key, raw.hasOwnProperty(prop));

case 'length':
return getFilteredCount(raw, key, nodeIsAccessible);

Expand Down Expand Up @@ -9523,7 +9566,7 @@ function SecureWindow(sandbox, key) {
if (confirmLocationChange(win.location.href, href)) {
const filteredArgs = filterArguments(o, [href, ...args]);
const res = win.open(...filteredArgs);
return typeof res === 'object' ? SecureIFrameContentWindow(res, key) : res;
return isWindowLikeObject(res) ? SecureIFrameContentWindow(res, key) : res;
}
// window.open spec expects a null return value if the operation fails
return null;
Expand Down
Loading

0 comments on commit 1f39aec

Please sign in to comment.