This commit is contained in:
1 parent
7b43d260a2
commit
4357ce4094
9 files changed
+337
-100
No files matched your search
@@ -185,4 +185,35 @@ describe('Data flow: popup -> storage -> viewer', () => {
|
||||
throw new Error('Entry with invalid mediaType should be rejected');
|
||||
}
|
||||
});
|
||||
|
||||
it('an HLS entry carrying a scan-time referer passes schema + round-trips', () => {
|
||||
// The referer is bound to the entry at scan time so it survives the
|
||||
// watch-later flow (the source tab may be long closed). Because the schema
|
||||
// sets additionalProperties:false, a `referer` the store carries must be an
|
||||
// explicit property or storage-layer validation would reject the entry.
|
||||
const scrapedEntry = {
|
||||
url: 'https://pageA.example.com/watch',
|
||||
src: 'https://hv-h.phncdn.com/hls/live/master.m3u8',
|
||||
hlsManifest: 'https://hv-h.phncdn.com/hls/live/master.m3u8',
|
||||
mediaType: 'hls',
|
||||
poster: 'https://pageA.example.com/thumb.jpg',
|
||||
tab: 'Referer-protected stream',
|
||||
referer: 'https://pageA.example.com/watch',
|
||||
};
|
||||
|
||||
const valid = validate(scrapedEntry);
|
||||
if (!valid) {
|
||||
throw new Error(`Entry with referer fails schema: ${JSON.stringify(validate.errors)}`);
|
||||
}
|
||||
|
||||
// The referer must survive the storage round-trip intact so the viewer can
|
||||
// send it to the proxy when the user opens a previously-scanned entry.
|
||||
const roundTripped = JSON.parse(JSON.stringify(scrapedEntry));
|
||||
if (roundTripped.referer !== 'https://pageA.example.com/watch') {
|
||||
throw new Error('referer lost during round-trip');
|
||||
}
|
||||
if (!validate(roundTripped)) {
|
||||
throw new Error('Round-tripped entry with referer fails schema');
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user