Skip to content

Commit 355ea73

Browse files
authored
feat: actually bundle FFMPEG binaries with NPM packages (microsoft#3804)
This patch: - adds FFMPEG binaries to the NPM packages - adds a screencast test to make sure that screencast works. This currently relies on private screencast APIs. NOTE: with this patch playwright package size grows from `650KB` to `4.2MB`.
1 parent e9f4843 commit 355ea73

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

packages/common/.npmignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# Exclude injected files. A preprocessed version of these is included via lib/generated.
1212
# See src/server/injected/README.md.
1313
lib/server/injected/
14-
# Include Windows dependency checker executable.
15-
!bin/PrintDeps.exe
14+
# Include all binaries that we ship with the package.
15+
!bin/*
1616
# Include generated types and entrypoint.
1717
!types/*
1818
!index.d.ts

packages/installation-tests/installation-tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ NODE_VERSION="$(node --version)"
2929

3030
function copy_test_scripts {
3131
cp "${SCRIPTS_PATH}/sanity.js" .
32+
cp "${SCRIPTS_PATH}/screencast.js" .
3233
cp "${SCRIPTS_PATH}/esm.mjs" .
3334
cp "${SCRIPTS_PATH}/esm-playwright.mjs" .
3435
cp "${SCRIPTS_PATH}/esm-playwright-chromium.mjs" .
@@ -39,6 +40,7 @@ function copy_test_scripts {
3940
}
4041

4142
function run_tests {
43+
test_screencast
4244
test_typescript_types
4345
test_skip_browser_download
4446
test_playwright_global_installation_subsequent_installs
@@ -52,6 +54,22 @@ function run_tests {
5254
test_electron_types
5355
}
5456

57+
function test_screencast {
58+
initialize_test "${FUNCNAME[0]}"
59+
copy_test_scripts
60+
61+
local BROWSERS="$(pwd -P)/browsers"
62+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
63+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_FIREFOX_TGZ}
64+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_WEBKIT_TGZ}
65+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_CHROMIUM_TGZ}
66+
67+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node screencast.js playwright
68+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node screencast.js playwright-chromium
69+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node screencast.js playwright-webkit
70+
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" node screencast.js playwright-firefox
71+
}
72+
5573
function test_typescript_types {
5674
initialize_test "${FUNCNAME[0]}"
5775

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const requireName = process.argv[2];
18+
let success = {
19+
'playwright': ['chromium', 'firefox', 'webkit'],
20+
'playwright-chromium': ['chromium'],
21+
'playwright-firefox': ['firefox'],
22+
'playwright-webkit': ['webkit'],
23+
}[requireName];
24+
if (process.argv[3] === 'none')
25+
success = [];
26+
if (process.argv[3] === 'all')
27+
success = ['chromium', 'firefox', 'webkit'];
28+
29+
const playwright = require(requireName);
30+
const path = require('path');
31+
const fs = require('fs');
32+
33+
(async () => {
34+
for (const browserType of success) {
35+
try {
36+
const browser = await playwright[browserType].launch({
37+
_videosPath: __dirname,
38+
});
39+
const context = await browser.newContext({
40+
_recordVideos: {width: 320, height: 240},
41+
});
42+
const page = await context.newPage();
43+
const video = await page.waitForEvent('_videostarted');
44+
// Wait fo 1 second to actually record something.
45+
await new Promise(x => setTimeout(x, 1000));
46+
const [videoFile] = await Promise.all([
47+
video.path(),
48+
context.close(),
49+
]);
50+
await browser.close();
51+
if (!fs.existsSync(videoFile)) {
52+
console.error(`ERROR: Package "${requireName}", browser "${browserType}" should have created screencast!`);
53+
process.exit(1);
54+
}
55+
} catch (err) {
56+
console.error(`ERROR: Should be able to launch ${browserType} from ${requireName}`);
57+
console.error(err);
58+
process.exit(1);
59+
}
60+
}
61+
})();

0 commit comments

Comments
 (0)