Skip to content

Commit 980ec3a

Browse files
committed
test
1 parent 67cf76a commit 980ec3a

File tree

2 files changed

+1
-106
lines changed

2 files changed

+1
-106
lines changed

.github/workflows/CI.yml

+1-95
Original file line numberDiff line numberDiff line change
@@ -89,99 +89,5 @@ jobs:
8989
node-modules-
9090
- name: Install dependencies
9191
run: npm install
92-
- name: Install Chrome
93-
uses: browser-actions/setup-chrome@latest
94-
with:
95-
chrome-version: stable
9692
- name: Run tests
97-
env:
98-
CHROME_HEADLESS: 1
99-
CHROME_PATH: chrome
100-
CHROME_FLAGS: "--headless --disable-gpu --no-sandbox --enable-features=SharedArrayBuffer,CrossOriginIsolation"
101-
HEADERS: '{"Cross-Origin-Opener-Policy":"same-origin","Cross-Origin-Embedder-Policy":"require-corp","Cross-Origin-Resource-Policy":"cross-origin","Origin-Agent-Cluster":"?1"}'
102-
run: |
103-
# Start test server with proper headers
104-
npm run serve -- --headers "${HEADERS}" &
105-
106-
# Increase wait time to ensure server is ready
107-
sleep 15
108-
109-
# Verify headers and isolation status
110-
echo "Checking security headers and isolation status..."
111-
curl -I http://localhost:3000/tests/ffmpeg-core-st.test.html
112-
113-
# Run verification script first
114-
echo "Verifying browser environment..."
115-
cat << EOF > verify-browser.html
116-
<!DOCTYPE html>
117-
<html>
118-
<head>
119-
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin">
120-
<meta http-equiv="Cross-Origin-Embedder-Policy" content="require-corp">
121-
</head>
122-
<body>
123-
<script>
124-
console.log('SharedArrayBuffer available:', typeof SharedArrayBuffer !== 'undefined');
125-
console.log('crossOriginIsolated:', window.crossOriginIsolated);
126-
if (!window.crossOriginIsolated || typeof SharedArrayBuffer === 'undefined') {
127-
throw new Error('Browser environment not properly configured for SharedArrayBuffer');
128-
}
129-
</script>
130-
</body>
131-
</html>
132-
EOF
133-
134-
# Run single-threaded tests first
135-
echo "Running single-threaded tests..."
136-
npx mocha-headless-chrome \
137-
--args="$CHROME_FLAGS" \
138-
-a no-sandbox \
139-
-f http://localhost:3000/tests/ffmpeg-core-st.test.html 2>&1 | tee st-core-test.log
140-
141-
npx mocha-headless-chrome \
142-
--args="$CHROME_FLAGS" \
143-
-a no-sandbox \
144-
-f http://localhost:3000/tests/ffmpeg-st.test.html 2>&1 | tee st-test.log
145-
146-
# Run multi-threaded tests
147-
echo "Running multi-threaded tests..."
148-
# Create a test script to verify browser environment
149-
cat << EOF > verify-browser.html
150-
<!DOCTYPE html>
151-
<html>
152-
<head>
153-
<title>Browser Environment Test</title>
154-
</head>
155-
<body>
156-
<script>
157-
console.log('SharedArrayBuffer available:', typeof SharedArrayBuffer !== 'undefined');
158-
console.log('crossOriginIsolated:', window.crossOriginIsolated);
159-
</script>
160-
</body>
161-
</html>
162-
EOF
163-
164-
# Run the verification in Chrome
165-
echo "Verifying browser environment..."
166-
npx mocha-headless-chrome \
167-
--args="$CHROME_FLAGS --enable-features=SharedArrayBuffer,CrossOriginIsolation" \
168-
-a no-sandbox \
169-
-f http://localhost:3000/verify-browser.html
170-
171-
# Run MT tests with verified configuration
172-
npx mocha-headless-chrome \
173-
--args="$CHROME_FLAGS --enable-features=SharedArrayBuffer,CrossOriginIsolation" \
174-
-a no-sandbox \
175-
-f http://localhost:3000/tests/ffmpeg-core-mt.test.html 2>&1 | tee mt-core-test.log
176-
177-
npx mocha-headless-chrome \
178-
--args="$CHROME_FLAGS --enable-features=SharedArrayBuffer,CrossOriginIsolation" \
179-
-a no-sandbox \
180-
-f http://localhost:3000/tests/ffmpeg-mt.test.html 2>&1 | tee mt-test.log
181-
182-
# Display all logs for debugging
183-
echo "=== Test Logs ==="
184-
for log in *-test.log; do
185-
echo "Contents of $log:"
186-
cat $log
187-
done
93+
run: npm test

tests/ffmpeg-core.test.js

-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
const isMTSupported = typeof SharedArrayBuffer !== "undefined";
2-
const isIsolated = window.crossOriginIsolated;
3-
4-
if (FFMPEG_TYPE === "mt" && !isMTSupported) {
5-
console.warn("SharedArrayBuffer not available, skipping MT tests");
6-
}
7-
8-
if (FFMPEG_TYPE === "mt" && !isIsolated) {
9-
console.warn("Cross-origin isolation not available, skipping MT tests");
10-
}
11-
121
let core;
132

143
const genName = (name) => `[ffmpeg-core][${FFMPEG_TYPE}] ${name}`;

0 commit comments

Comments
 (0)