-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support skipping cache and storage clear #1675
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,6 +225,60 @@ describe('GatherRunner', function() { | |
}); | ||
}); | ||
|
||
it('clears the network cache and origin storage', () => { | ||
const asyncFunc = () => Promise.resolve(); | ||
const tests = { | ||
calledDisableNetworkCache: false, | ||
calledClearStorage: false, | ||
}; | ||
const createCheck = variable => () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be nice to replace fake-driver with a nice interface around something like this :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or we could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I'd be fine with that too. Honestly I hate these tests involving the driver. Rely too much on knowledge of internal implementation instead of externally observable behavior. If we're going to assume the driver calls made and the order they're made in, I'd rather we just setup a debugger protocol record/replay system :) |
||
tests[variable] = true; | ||
return Promise.resolve(); | ||
}; | ||
const driver = { | ||
assertNoSameOriginServiceWorkerClients: asyncFunc, | ||
beginEmulation: asyncFunc, | ||
enableRuntimeEvents: asyncFunc, | ||
cacheNatives: asyncFunc, | ||
cleanAndDisableBrowserCaches: createCheck('calledDisableNetworkCache'), | ||
clearDataForOrigin: createCheck('calledClearStorage'), | ||
blockUrlPatterns: asyncFunc, | ||
}; | ||
|
||
return GatherRunner.setupDriver(driver, {flags: {}}).then(_ => { | ||
assert.equal(tests.calledDisableNetworkCache, true); | ||
assert.equal(tests.calledClearStorage, true); | ||
}); | ||
}); | ||
|
||
it('does not clear the network cache and origin storage when flag is set', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...when disable-storage-reset flag is set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
const asyncFunc = () => Promise.resolve(); | ||
const tests = { | ||
calledDisableNetworkCache: false, | ||
calledClearStorage: false, | ||
}; | ||
const createCheck = variable => () => { | ||
tests[variable] = true; | ||
return Promise.resolve(); | ||
}; | ||
const driver = { | ||
assertNoSameOriginServiceWorkerClients: asyncFunc, | ||
beginEmulation: asyncFunc, | ||
enableRuntimeEvents: asyncFunc, | ||
cacheNatives: asyncFunc, | ||
cleanAndDisableBrowserCaches: createCheck('calledDisableNetworkCache'), | ||
clearDataForOrigin: createCheck('calledClearStorage'), | ||
blockUrlPatterns: asyncFunc, | ||
}; | ||
|
||
return GatherRunner.setupDriver(driver, { | ||
flags: {disableCacheClearing: true} | ||
}).then(_ => { | ||
assert.equal(tests.calledDisableNetworkCache, false); | ||
assert.equal(tests.calledClearStorage, false); | ||
}); | ||
}); | ||
|
||
it('tells the driver to block given URL patterns when blockedUrlPatterns is given', () => { | ||
const receivedUrlPatterns = []; | ||
const urlPatterns = ['http://*.evil.com', '.jpg', '.woff2']; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other name ideas welcome, cache is more specific than what actually happens but is probably more familiar/understandable to users than a generic
storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disable-storage-reset
comes to mind. I actually think being more generic than "cache" is good for the reasons you mention. It applies to all forms of storage on the origin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do