fix(ses): Address charset error in integration
MODIFY
packages/ses-integration-test/puppeteer-test/utility/test-bundler.js
packages/ses-integration-test/puppeteer-test/utility/test-bundler.js
@@ -4,7 +4,10 @@ import test from 'tape-promise/tape';
import path from 'path';
const runBrowserTests = async (t, indexFile) => {
- const browser = await puppeteer.launch();
+ const browser = await puppeteer.launch({
+ // debug:
+ // { headless: false }
+ });
let numTests;
let numPass;
@@ -62,7 +65,7 @@ const testBundler = (bundlerName, indexFile) => {
t.notEqual(numTests, undefined);
t.equal(numTests, numPass);
})
- .catch(e => t.isNot(e, e, 'unexpected exception'))
+ .catch(e => t.fail(`Unexpected exception ${e}`))
.finally(() => t.end());
});
};

MODIFY
packages/ses-integration-test/scaffolding/mock-unpkg-umd/index.html
packages/ses-integration-test/scaffolding/mock-unpkg-umd/index.html
<html>
<head>
<title>Test</title>
+ <meta charset="utf8">
</head>
<body>
<script src="../../../ses/dist/ses.umd.js"></script>

MODIFY
packages/ses/NEWS.md
packages/ses/NEWS.md
@@ -20,6 +20,13 @@ User-visible changes in SES:
The constructor must perform the module analysis and transform the source,
and present this duck-type to the Compartment `importHook`.
This relieves SES of a dependency on Babel and simplifies its API.
+- *BREAKING CHANGE* The UMD distribution of SES must have the UTF-8 charset.
+ The prior versions were accidentally ASCII, so SES would have worked
+ in any web page, regardless of the charset.
+ To remedy this, be sure to include `<head><meta charset="utf-8"></head>` in
+ the containing page (a general best-practice for web pages) or specifically
+ use `<script charset="utf-8" src="ses.umd.min.js">` to address the single
+ file.
- Relaxes the censorship of `import` and `eval` in programs evaluated
under SES to specifically allow the use of `something.import()` or
`something.eval()` methods.

MODIFY
packages/ses/README.md
packages/ses/README.md
@@ -48,6 +48,13 @@ npm install ses
## Usage
+SES is a shim that can be run in most engines, either as an ESM module `ses` or
+as a `<script>` tag.
+For a script tag, the content encoding charset must be UTF-8, either by virtue
+of `<head><meta charset="utf-8"></head>` (a general best practice for all HTML
+files) or specifically `<script src="node_modules/ses/dist/ses.umd.min.js"
+charset="utf-8">`.
+
### Lockdown
SES introduces the `lockdown()` function.

MODIFY
packages/ses/scripts/bundle.js
packages/ses/scripts/bundle.js
import '../index.js';
import fs from 'fs';
import { makeBundle } from '@agoric/compartment-mapper';
-import prettier from 'prettier';
import terser from 'terser';
const resolve = (rel, abs) => new URL(rel, abs).toString();
@@ -18,19 +17,21 @@ const write = async (target, content) => {
read,
resolve('../index.js', import.meta.url),
);
- const pretty = prettier.format(bundle);
- const { code: terse } = terser.minify(bundle);
+ const { code: terse } = terser.minify(bundle, {
+ mangle: false,
+ keep_classnames: true,
+ });
- console.log(`Bundle size: ${pretty.length} bytes`);
+ console.log(`Bundle size: ${bundle.length} bytes`);
console.log(`Minified bundle size: ${terse.length} bytes`);
- await write('dist/ses.cjs', pretty);
- await write('dist/ses.mjs', pretty);
- await write('dist/ses.umd.js', pretty);
+ await write('dist/ses.cjs', bundle);
+ await write('dist/ses.mjs', bundle);
+ await write('dist/ses.umd.js', bundle);
await write('dist/ses.umd.min.js', terse);
- await write('dist/lockdown.cjs', pretty);
- await write('dist/lockdown.mjs', pretty);
- await write('dist/lockdown.umd.js', pretty);
+ await write('dist/lockdown.cjs', bundle);
+ await write('dist/lockdown.mjs', bundle);
+ await write('dist/lockdown.umd.js', bundle);
await write('dist/lockdown.umd.min.js', terse);
})();

fix(ses): Address charset error in integration