Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workaround for pywb's wombat.js bug #6356

Merged
merged 1 commit into from
May 7, 2024
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
12 changes: 2 additions & 10 deletions src/annotator/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type SidebarContainerConfig = {
/**
* Create the iframe that will load the sidebar application.
*/
export function createSidebarIframe(config: SidebarConfig): HTMLIFrameElement {
function createSidebarIframe(config: SidebarConfig): HTMLIFrameElement {
const sidebarURL = config.sidebarAppUrl;
const sidebarAppSrc = addConfigFragment(
sidebarURL,
Expand All @@ -87,15 +87,7 @@ export function createSidebarIframe(config: SidebarConfig): HTMLIFrameElement {
// the clipboard.
sidebarFrame.allow = 'fullscreen; clipboard-write';

// In viahtml, pywb uses wombat.js, which monkey-patches some JS methods.
// One of those causes the `allow` attribute to be overwritten, so we want to
// define a noop setter to preserve the permissions we set above.
// We can remove this workaround once pywb has been updated to use the latest
// version of wombat.js, which includes a fix for this.
// See https://github.com/webrecorder/wombat/pull/134
return Object.defineProperty(sidebarFrame, 'allow', {
set: () => {},
});
return sidebarFrame;
}

type GestureState = {
Expand Down
13 changes: 1 addition & 12 deletions src/annotator/test/sidebar-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TinyEmitter } from 'tiny-emitter';

import { addConfigFragment } from '../../shared/config-fragment';
import { Sidebar, MIN_RESIZE, $imports, createSidebarIframe } from '../sidebar';
import { Sidebar, MIN_RESIZE, $imports } from '../sidebar';
import { Emitter } from '../util/emitter';

const DEFAULT_WIDTH = 350;
Expand Down Expand Up @@ -1138,15 +1138,4 @@ describe('Sidebar', () => {
assert.calledWith(guestRPC().call, 'selectAnnotations', tags, true);
});
});

describe('createSidebarIframe', () => {
it('does not let `allow` attribute to be overwritten', () => {
const iframe = createSidebarIframe({ sidebarAppUrl: 'https://foo.com' });
const initialAllow = iframe.allow;

iframe.allow = 'something else';

assert.equal(iframe.allow, initialAllow);
});
});
});