Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(options: DocumentWidget.IOptionsOptionalContent) {
super({
...options,
content: new IFrame({ sandbox: ['allow-same-origin'] })
});
this.content.addClass(CSS_CLASS);
void this.context.ready.then(() => {
this.update();
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: this.context.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(this.update, this);
});
// Make a refresh button for the toolbar.
this.toolbar.addItem(
'refresh',
function newHelpWidget(url: string, text: string): MainAreaWidget {
// Allow scripts and forms so that things like
// readthedocs can use their search functionality.
// We *don't* allow same origin requests, which
// can prevent some content from being loaded onto the
// help pages.
let content = new IFrame({
sandbox: ['allow-scripts', 'allow-forms']
});
content.url = url;
content.addClass(HELP_CLASS);
content.title.label = text;
content.id = `${namespace}-${++counter}`;
let widget = new MainAreaWidget({ content });
widget.addClass('jp-Help');
return widget;
}
constructor() {
super({
// Disable allow some iframe extensions to let server requests
// and scripts to execute in the bokeh server context.
// This is unsafe, but we presumably trust the code in the bokeh server.
content: new IFrame({ sandbox: ['allow-scripts', 'allow-same-origin'] })
});
this._inactivePanel = Private.createInactivePanel();
this.content.node.appendChild(this._inactivePanel);
this.update();
}
it('should be the url of the iframe', () => {
let iframe = new IFrame();
expect(iframe.url).to.equal('');
iframe.url = 'foo';
expect(iframe.url).to.equal('foo');
});
});
it('should set the referrer policy for the iframe.', () => {
let iframe = new IFrame({ referrerPolicy: 'unsafe-url' });
let node = iframe.node.querySelector('iframe')!;
expect(iframe.referrerPolicy).to.equal('unsafe-url');
iframe.referrerPolicy = 'origin';
expect(iframe.referrerPolicy).to.equal('origin');
expect(node.getAttribute('referrerpolicy')).to.equal('origin');
});
});
it('should create a new iframe widget', () => {
let iframe = new IFrame();
expect(iframe).to.be.an.instanceof(IFrame);
expect(iframe.hasClass('jp-IFrame')).to.equal(true);
expect(iframe.node.querySelector('iframe')).to.be.ok;
});
it('should set the exceptions for the sandbox attribute.', () => {
let iframe = new IFrame({
sandbox: ['allow-scripts', 'allow-same-origin']
});
let node = iframe.node.querySelector('iframe')!;
expect(iframe.sandbox).to.deep.equal([
'allow-scripts',
'allow-same-origin'
]);
iframe.sandbox = ['allow-pointer-lock'];
expect(iframe.sandbox).to.deep.equal(['allow-pointer-lock']);
expect(node.getAttribute('sandbox')).to.equal('allow-pointer-lock');
});
});
constructor(url: string) {
super();
let layout = this.layout = new PanelLayout();
let iframe = new IFrame();
iframe.url = url;
layout.addWidget(iframe);
}
constructor() {
super({ content: new IFrame() });
this.content.url = '';
}
constructor() {
super({
content: new IFrame({ sandbox: ['allow-scripts', 'allow-same-origin'] })
});
this._inactivePanel = Private.createInactivePanel();
this.content.node.appendChild(this._inactivePanel);
this.update();
}