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

Commit fa2034c

Browse files
committed
test($sanitize): skip nextSibling clobber test on Edge 16
In some circumstances, Edge 16 will not throw on clobbered elements, because the nextSibling property is null. The exact cause is currently unknown.
1 parent 750b43b commit fa2034c

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

test/ngSanitize/sanitizeSpec.js

+27-14
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,37 @@ describe('HTML', function() {
246246
.toEqual('<p>text1text2</p>');
247247
});
248248

249-
it('should throw on clobbered elements', function() {
250-
inject(function($sanitize) {
251-
expect(function() {
252-
$sanitize('<form><input name="parentNode" /></form>');
253-
}).toThrowMinErr('$sanitize', 'elclob');
249+
describe('clobbered elements', function() {
254250

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

259-
expect(function() {
260-
$sanitize('<form><input name="nextSibling" /></form>');
261-
}).toThrowMinErr('$sanitize', 'elclob');
254+
expect(function() {
255+
$sanitize('<form><input name="parentNode" /></form>');
256+
}).toThrowMinErr('$sanitize', 'elclob');
262257

263-
expect(function() {
264-
$sanitize('<form><div><div><input name="nextSibling" /></div></div></form>');
265-
}).toThrowMinErr('$sanitize', 'elclob');
258+
expect(function() {
259+
$sanitize('<form><div><div><input name="parentNode" /></div></div></form>');
260+
}).toThrowMinErr('$sanitize', 'elclob');
261+
});
266262
});
263+
264+
if (!/Edge\/16/.test(window.navigator.userAgent)) {
265+
// Skip test on Edge 16 due to browser bug.
266+
it('should throw on a form with an input named "nextSibling"', function() {
267+
inject(function($sanitize) {
268+
269+
expect(function() {
270+
$sanitize('<form><input name="nextSibling" /></form>');
271+
}).toThrowMinErr('$sanitize', 'elclob');
272+
273+
expect(function() {
274+
$sanitize('<form><div><div><input name="nextSibling" /></div></div></form>');
275+
}).toThrowMinErr('$sanitize', 'elclob');
276+
277+
});
278+
});
279+
}
267280
});
268281

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

0 commit comments

Comments
 (0)