Closed Bug 1364082 Opened 7 years ago Closed 7 years ago

Improve test about file save in JSON Viewer

Categories

(DevTools :: JSON Viewer, enhancement, P3)

enhancement

Tracking

(firefox55 fixed)

RESOLVED FIXED
Firefox 55
Tracking Status
firefox55 --- fixed

People

(Reporter: Oriol, Assigned: Oriol)

Details

Attachments

(1 file, 2 obsolete files)

Attached patch json-save-test.patch (obsolete) — Splinter Review
Currently there is only a very basic test about saving in JSON Viewer. It needs to be improved with the new features from bug 1349437 and bug 1327784.
Attachment #8866788 - Flags: review?(odvarko)
Comment on attachment 8866788 [details] [diff] [review]
json-save-test.patch

Review of attachment 8866788 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for the patch!

I am seeing following failure when running the test (Win10):

The following tests failed:
13 INFO TEST-UNEXPECTED-FAIL | devtools/client/jsonview/test/browser_jsonview_save_json.js | Exception thrown - Error opening input stream (invalid filename?): chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js
Buffered messages finished
SUITE-END | took 7s


Honza
Attachment #8866788 - Flags: review?(odvarko)
Attached patch json-save-test-v2.patch (obsolete) — Splinter Review
It seems I needed to reference mockTransfer.js in support-files.
Attachment #8866788 - Attachment is obsolete: true
Attachment #8867695 - Flags: review?(odvarko)
Comment on attachment 8867695 [details] [diff] [review]
json-save-test-v2.patch

Review of attachment 8867695 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for the patch!

Please read my inline comments.

Honza

::: devtools/client/jsonview/test/browser_jsonview_save_json.js
@@ +13,5 @@
>  
>  let { MockFilePicker } = SpecialPowers;
> +MockFilePicker.init(window);
> +MockFilePicker.returnValue = MockFilePicker.returnOK;
> +var mockTransferCallback, mockTransferRegisterer;

nit style: Define vars independently

var mockTransferCallback;
var mockTransferRegisterer;

@@ +22,5 @@
>  
> +function click(selector) {
> +  return BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, gBrowser.selectedBrowser);
> +}
> +function rightClick(selector) {

Separate function definitions with one empty line.

@@ +44,5 @@
> +        ok(downloadSuccess, "JSON should have been downloaded successfully");
> +        ok(destFile.exists(), "The downloaded file should exist.");
> +        resolve(destFile);
> +      };
> +      void mockTransferCallback; // Needed by eslint

Use `/* eslint-disable no-unused-vars */` at the top of the file instead

@@ +71,5 @@
> +    saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
> +  }
> +  info("Temporary save directory: " + saveDir.path);
> +  return saveDir;
> +}

nit: Insert one empty line here

@@ +101,5 @@
> +  yield new Promise((resolve) => {
> +    info("Register to handle popupshown.");
> +    document.addEventListener("popupshown", function listener(event) {
> +      info("Context menu opened.");
> +      document.removeEventListener("popupshown", listener);

Instead of adding and removing a listener you can use 'once' argument. 
See: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
Attachment #8867695 - Flags: review?(odvarko)
Attachment #8867695 - Attachment is obsolete: true
Attachment #8868091 - Flags: review?(odvarko)
Comment on attachment 8868091 [details] [diff] [review]
json-save-test-v3.patch

Review of attachment 8868091 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, thanks for working on this!

Honza
Attachment #8868091 - Flags: review?(odvarko) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/420d6714a827
Improve test about file save in JSON Viewer. r=Honza
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/420d6714a827
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: