update assertion

This commit is contained in:
Simon Knott 2025-02-03 14:43:17 +01:00
parent c2826f0aeb
commit 36855598be
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 3 additions and 1 deletions

View file

@ -201,6 +201,8 @@ export class Request extends ChannelOwner<channels.RequestChannel> implements ap
} }
frame(): Frame { frame(): Frame {
if (this._pageForMockingProxy)
throw new Error('Frame for this request is not available, because the request was issued on the server.');
if (!this._initializer.frame) { if (!this._initializer.frame) {
assert(this.serviceWorker()); assert(this.serviceWorker());
throw new Error('Service Worker requests do not have an associated frame.'); throw new Error('Service Worker requests do not have an associated frame.');

View file

@ -110,7 +110,7 @@ test('all properties are populated', async ({ runInlineTest, server, request })
expect(await response.finished()).toBe(null); expect(await response.finished()).toBe(null);
expect(request.serviceWorker()).toBe(null); expect(request.serviceWorker()).toBe(null);
expect(() => request.frame()).toThrowError("Assertion error"); // we know the page, but not the frame. should probably improve the error message expect(() => request.frame()).toThrowError("Frame for this request is not available, because the request was issued on the server.");
expect(request.failure()).toBe(null); expect(request.failure()).toBe(null);
expect(request.isNavigationRequest()).toBe(false); expect(request.isNavigationRequest()).toBe(false);