Closed
Bug 1257583
Opened 9 years ago
Closed 9 years ago
Add test for bypassing the cache with tabs.reload
Categories
(WebExtensions :: Untriaged, defect)
WebExtensions
Untriaged
Tracking
(firefox48 fixed)
| Tracking | Status | |
|---|---|---|
| firefox48 | --- | fixed |
People
(Reporter: mattw, Assigned: mattw)
References
Details
Attachments
(1 file)
We currently don't have any tests to ensure that `tabs.reload(tabId, {bypassCache: true})` is working as intended.
| Assignee | ||
Updated•9 years ago
|
Iteration: 48.1 - Mar 21 → ---
Updated•9 years ago
|
Assignee: nobody → mwein
| Assignee | ||
Updated•9 years ago
|
Iteration: --- → 48.3 - Apr 18
| Assignee | ||
Comment 1•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/44239/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/44239/
Attachment #8737992 -
Flags: review?(kmaglione+bmo)
Updated•9 years ago
|
Attachment #8737992 -
Flags: review?(kmaglione+bmo)
Comment 2•9 years ago
|
||
Comment on attachment 8737992 [details]
MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload.
https://reviewboard.mozilla.org/r/44239/#review40923
Looks good. Just needs a bit of refactoring and one more test.
::: browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js:17
(Diff revision 1)
> + const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
> + const URL = BASE + "file_bypass_cache.sjs";
> +
> + browser.tabs.create({url: URL}).then((tab) => {
> + return new Promise(resolve => {
> + browser.tabs.onUpdated.addListener(function listener(tabId, changed, tab_) {
Can you move this into a helper function and use it for both tests?
::: browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js:35
(Diff revision 1)
> + if (changed.url == URL) {
> + browser.tabs.executeScript(tabId, {
> + code: "document.body.textContent",
> + }).then(textContent => {
> + let [pragma, cacheControl] = textContent.split(":");
> + browser.test.assertTrue(pragma == "no-cache" && cacheControl == "no-cache", "The correct headers should be set for bypassing the cache");
browser.test.assertEq("no-cache", pragma, ...);
browser.test.assertEq("no-cache", cacheControl, ...);
::: browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js:37
(Diff revision 1)
> + code: "document.body.textContent",
> + }).then(textContent => {
> + let [pragma, cacheControl] = textContent.split(":");
> + browser.test.assertTrue(pragma == "no-cache" && cacheControl == "no-cache", "The correct headers should be set for bypassing the cache");
> + browser.tabs.remove(tabId);
> + browser.test.notifyPass("tabs.reload_bypass_cache");
We should also test without `bypassCache`.
::: browser/components/extensions/test/browser/file_bypass_cache.sjs:6
(Diff revision 1)
> +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
> +/* vim: set sts=2 sw=2 et tw=80 ft=javascript: */
> +"use strict";
> +
> +function handleRequest(request, response) {
> + response.processAsync();
This isn't necessary. Neither is the `.finish()`
::: browser/components/extensions/test/browser/file_bypass_cache.sjs:8
(Diff revision 1)
> +"use strict";
> +
> +function handleRequest(request, response) {
> + response.processAsync();
> + response.setHeader("Content-Type", "text/plain; charset=UTF-8", false);
> + response.write(request._headers._headers.pragma);
These are private members. Please use `request.getHeader(...)` instead.
| Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8737992 [details]
MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/44239/diff/1-2/
Attachment #8737992 -
Flags: review?(kmaglione+bmo)
Comment 4•9 years ago
|
||
Comment on attachment 8737992 [details]
MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload.
https://reviewboard.mozilla.org/r/44239/#review41413
Looks good. Thanks
::: browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js:49
(Diff revision 2)
> + let [pragma, cacheControl] = textContent.split(":");
> + browser.test.assertEq("no-cache", pragma, "`pragma` should be set to `no-cache` when bypassCache is true");
> + browser.test.assertEq("no-cache", cacheControl, "`cacheControl` should be set to `no-cache` when bypassCache is true");
> + browser.tabs.remove(tabId);
> + browser.test.notifyPass("tabs.reload_bypass_cache");
> + });
Please add:
)}.catch(e => {
browser.test.fail(`Error: ${e} :: ${e.stack}`);
browser.test.notifyFail("tabs.reload_bypass_cache");
});
Attachment #8737992 -
Flags: review?(kmaglione+bmo) → review+
| Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8737992 [details]
MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/44239/diff/2-3/
| Assignee | ||
Comment 6•9 years ago
|
||
| Assignee | ||
Comment 7•9 years ago
|
||
Comment on attachment 8737992 [details]
MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/44239/diff/3-4/
Attachment #8737992 -
Attachment description: MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload r?kmag → MozReview Request: Bug 1257583 - Add test for bypassing the cache with tabs.reload.
| Assignee | ||
Comment 8•9 years ago
|
||
| Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Keywords: checkin-needed
Comment 10•9 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Updated•7 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•