Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test($sanitize): skip clobber test on Edge #16388

Merged
merged 3 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion karma-shared.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ module.exports = function(config, specificOptions) {
if (process.env.TRAVIS) {
var buildLabel = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';

config.logLevel = config.LOG_DEBUG;
// Karma (with socket.io 1.x) buffers by 50 and 50 tests can take a long time on IEs;-)
config.browserNoActivityTimeout = 120000;

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"gulp-sourcemaps": "^1.2.2",
"gulp-uglify": "^1.0.1",
"gulp-util": "^3.0.1",
"jasmine-core": "2.5.2",
"jasmine-core": "^2.8.0",
"jasmine-node": "^2.0.0",
"jasmine-reporters": "^2.2.0",
"jquery": "^3.2.1",
"karma": "^1.7.0",
"karma": "^2.0.0",
"karma-browserstack-launcher": "^1.2.0",
"karma-chrome-launcher": "^2.1.1",
"karma-firefox-launcher": "^1.0.1",
Expand Down
5 changes: 4 additions & 1 deletion test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,10 +1035,13 @@ describe('angular', function() {

}

var originalFunction;
var originalPrototype = window.Function.prototype;

beforeEach(function() {
spyOn(window, 'Function');
// Jasmine 2.7+ doesn't support spying on Function, so we have restore the prototype
// as Jasmine will use Function internally
window.Function.prototype = originalPrototype;
});

afterEach(function() {
Expand Down
41 changes: 27 additions & 14 deletions test/ngSanitize/sanitizeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,37 @@ describe('HTML', function() {
.toEqual('<p>text1text2</p>');
});

it('should throw on clobbered elements', function() {
inject(function($sanitize) {
expect(function() {
$sanitize('<form><input name="parentNode" /></form>');
}).toThrowMinErr('$sanitize', 'elclob');
describe('clobbered elements', function() {

expect(function() {
$sanitize('<form><div><div><input name="parentNode" /></div></div></form>');
}).toThrowMinErr('$sanitize', 'elclob');
it('should throw on a form with an input named "parentNode"', function() {
inject(function($sanitize) {

expect(function() {
$sanitize('<form><input name="nextSibling" /></form>');
}).toThrowMinErr('$sanitize', 'elclob');
expect(function() {
$sanitize('<form><input name="parentNode" /></form>');
}).toThrowMinErr('$sanitize', 'elclob');

expect(function() {
$sanitize('<form><div><div><input name="nextSibling" /></div></div></form>');
}).toThrowMinErr('$sanitize', 'elclob');
expect(function() {
$sanitize('<form><div><div><input name="parentNode" /></div></div></form>');
}).toThrowMinErr('$sanitize', 'elclob');
});
});

if (!/Edge\/16/.test(window.navigator.userAgent)) {
// Skip test on Edge 16 due to browser bug.
it('should throw on a form with an input named "nextSibling"', function() {
inject(function($sanitize) {

expect(function() {
$sanitize('<form><input name="nextSibling" /></form>');
}).toThrowMinErr('$sanitize', 'elclob');

expect(function() {
$sanitize('<form><div><div><input name="nextSibling" /></div></div></form>');
}).toThrowMinErr('$sanitize', 'elclob');

});
});
}
});

// See https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
Expand Down
Loading