Skip to content
Open
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
46 changes: 45 additions & 1 deletion packages/core/test/render3/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {TestBed} from '../../testing';

import {getLContext, readPatchedData} from '../../src/render3/context_discovery';
import {CONTEXT, HEADER_OFFSET} from '../../src/render3/interfaces/view';
import {Sanitizer} from '../../src/sanitization/sanitizer';
import {SecurityContext} from '../../src/sanitization/dom_security_schema';
import {Sanitizer} from '../../src/sanitization/sanitizer';

describe('element discovery', () => {
it('should only monkey-patch immediate child nodes in a component', () => {
Expand Down Expand Up @@ -691,6 +691,50 @@ describe('sanitization', () => {
const fixture = TestBed.createComponent(TestComp);
expect(() => fixture.detectChanges()).not.toThrow();
});

it('should throw on uppercase iframe element', () => {
@Directive({
selector: '[unsafeUrlHostBindingDir]',
host: {
'[attr.src]': '"http://src-dir-value"',
},
})
class UnsafeUrlHostBindingDir {}

@Component({
imports: [UnsafeUrlHostBindingDir],
template: ` <IFRAME unsafeUrlHostBindingDir></IFRAME>`,
changeDetection: ChangeDetectionStrategy.Eager,
})
class SimpleComp {}

const fixture = TestBed.createComponent(SimpleComp);
expect(() => fixture.detectChanges()).toThrowError(
/NG0904: unsafe value used in a resource URL/,
);
});

it('should throw on uppercase SRC attribute on iframe element', () => {
@Directive({
selector: '[unsafeUrlHostBindingDir]',
host: {
'[attr.SRC]': '"http://src-dir-value"',
},
})
class UnsafeUrlHostBindingDir {}

@Component({
imports: [UnsafeUrlHostBindingDir],
template: ` <iframe unsafeUrlHostBindingDir></iframe>`,
changeDetection: ChangeDetectionStrategy.Eager,
})
class SimpleComp {}

const fixture = TestBed.createComponent(SimpleComp);
expect(() => fixture.detectChanges()).toThrowError(
/NG0904: unsafe value used in a resource URL/,
);
});
});

class LocalSanitizedValue {
Expand Down
Loading