Skip to content

Commit

Permalink
Remove workaround for pywb's wombat.js bug
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed May 7, 2024
1 parent 2c6db5c commit f4e5e98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
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);
});
});
});

0 comments on commit f4e5e98

Please sign in to comment.