summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/jsonview/test
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/jsonview/test')
-rw-r--r--devtools/client/jsonview/test/.eslintrc.js6
-rw-r--r--devtools/client/jsonview/test/array_json.json1
-rw-r--r--devtools/client/jsonview/test/array_json.json^headers^1
-rw-r--r--devtools/client/jsonview/test/browser.ini28
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_copy_headers.js35
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_copy_json.js31
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_copy_rawdata.js53
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_filter.js28
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_invalid_json.js20
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_save_json.js38
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_valid_json.js33
-rw-r--r--devtools/client/jsonview/test/doc_frame_script.js98
-rw-r--r--devtools/client/jsonview/test/head.js145
-rw-r--r--devtools/client/jsonview/test/invalid_json.json1
-rw-r--r--devtools/client/jsonview/test/invalid_json.json^headers^1
-rw-r--r--devtools/client/jsonview/test/simple_json.json1
-rw-r--r--devtools/client/jsonview/test/simple_json.json^headers^1
-rw-r--r--devtools/client/jsonview/test/valid_json.json6
-rw-r--r--devtools/client/jsonview/test/valid_json.json^headers^1
19 files changed, 528 insertions, 0 deletions
diff --git a/devtools/client/jsonview/test/.eslintrc.js b/devtools/client/jsonview/test/.eslintrc.js
new file mode 100644
index 000000000..8d15a76d9
--- /dev/null
+++ b/devtools/client/jsonview/test/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../.eslintrc.mochitests.js"
+};
diff --git a/devtools/client/jsonview/test/array_json.json b/devtools/client/jsonview/test/array_json.json
new file mode 100644
index 000000000..f91c3e08d
--- /dev/null
+++ b/devtools/client/jsonview/test/array_json.json
@@ -0,0 +1 @@
+[{"name": "jan"},{"name": "honza"},{"name": "odvarko"}]
diff --git a/devtools/client/jsonview/test/array_json.json^headers^ b/devtools/client/jsonview/test/array_json.json^headers^
new file mode 100644
index 000000000..6010bfd18
--- /dev/null
+++ b/devtools/client/jsonview/test/array_json.json^headers^
@@ -0,0 +1 @@
+Content-Type: application/json; charset=utf-8
diff --git a/devtools/client/jsonview/test/browser.ini b/devtools/client/jsonview/test/browser.ini
new file mode 100644
index 000000000..14f640c8c
--- /dev/null
+++ b/devtools/client/jsonview/test/browser.ini
@@ -0,0 +1,28 @@
+[DEFAULT]
+tags = devtools
+subsuite = devtools
+support-files =
+ array_json.json
+ array_json.json^headers^
+ doc_frame_script.js
+ head.js
+ invalid_json.json
+ invalid_json.json^headers^
+ simple_json.json
+ simple_json.json^headers^
+ valid_json.json
+ valid_json.json^headers^
+ !/devtools/client/commandline/test/head.js
+ !/devtools/client/framework/test/head.js
+ !/devtools/client/framework/test/shared-head.js
+
+[browser_jsonview_copy_headers.js]
+subsuite = clipboard
+[browser_jsonview_copy_json.js]
+subsuite = clipboard
+[browser_jsonview_copy_rawdata.js]
+subsuite = clipboard
+[browser_jsonview_filter.js]
+[browser_jsonview_invalid_json.js]
+[browser_jsonview_valid_json.js]
+[browser_jsonview_save_json.js]
diff --git a/devtools/client/jsonview/test/browser_jsonview_copy_headers.js b/devtools/client/jsonview/test/browser_jsonview_copy_headers.js
new file mode 100644
index 000000000..1ffe9f8ca
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_copy_headers.js
@@ -0,0 +1,35 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "valid_json.json";
+
+add_task(function* () {
+ info("Test valid JSON started");
+
+ yield addJsonViewTab(TEST_JSON_URL);
+
+ // Select the RawData tab
+ yield selectJsonViewContentTab("headers");
+
+ // Check displayed headers
+ let count = yield getElementCount(".headersPanelBox .netHeadersGroup");
+ is(count, 2, "There must be two header groups");
+
+ let text = yield getElementText(".headersPanelBox .netInfoHeadersTable");
+ isnot(text, "", "Headers text must not be empty");
+
+ let browser = gBrowser.selectedBrowser;
+
+ // Verify JSON copy into the clipboard.
+ yield waitForClipboardPromise(function setup() {
+ BrowserTestUtils.synthesizeMouseAtCenter(
+ ".headersPanelBox .toolbar button.copy",
+ {}, browser);
+ }, function validator(value) {
+ return value.indexOf("application/json") > 0;
+ });
+});
diff --git a/devtools/client/jsonview/test/browser_jsonview_copy_json.js b/devtools/client/jsonview/test/browser_jsonview_copy_json.js
new file mode 100644
index 000000000..b4c08b843
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_copy_json.js
@@ -0,0 +1,31 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "simple_json.json";
+
+add_task(function* () {
+ info("Test copy JSON started");
+
+ yield addJsonViewTab(TEST_JSON_URL);
+
+ let countBefore = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
+ ok(countBefore == 1, "There must be one row");
+
+ let text = yield getElementText(".jsonPanelBox .treeTable .treeRow");
+ is(text, "name\"value\"", "There must be proper JSON displayed");
+
+ // Verify JSON copy into the clipboard.
+ let value = "{\"name\": \"value\"}\n";
+ let browser = gBrowser.selectedBrowser;
+ let selector = ".jsonPanelBox .toolbar button.copy";
+ yield waitForClipboardPromise(function setup() {
+ BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
+ }, function validator(result) {
+ let str = normalizeNewLines(result);
+ return str == value;
+ });
+});
diff --git a/devtools/client/jsonview/test/browser_jsonview_copy_rawdata.js b/devtools/client/jsonview/test/browser_jsonview_copy_rawdata.js
new file mode 100644
index 000000000..d2346ea42
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_copy_rawdata.js
@@ -0,0 +1,53 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "simple_json.json";
+
+let jsonText = "{\"name\": \"value\"}\n";
+let prettyJson = "{\n \"name\": \"value\"\n}";
+
+add_task(function* () {
+ info("Test copy raw data started");
+
+ yield addJsonViewTab(TEST_JSON_URL);
+
+ // Select the RawData tab
+ yield selectJsonViewContentTab("rawdata");
+
+ // Check displayed JSON
+ let text = yield getElementText(".textPanelBox .data");
+ is(text, jsonText, "Proper JSON must be displayed in DOM");
+
+ let browser = gBrowser.selectedBrowser;
+
+ // Verify JSON copy into the clipboard.
+ yield waitForClipboardPromise(function setup() {
+ BrowserTestUtils.synthesizeMouseAtCenter(
+ ".textPanelBox .toolbar button.copy",
+ {}, browser);
+ }, jsonText);
+
+ // Click 'Pretty Print' button
+ yield BrowserTestUtils.synthesizeMouseAtCenter(
+ ".textPanelBox .toolbar button.prettyprint",
+ {}, browser);
+
+ let prettyText = yield getElementText(".textPanelBox .data");
+ prettyText = normalizeNewLines(prettyText);
+ ok(prettyText.startsWith(prettyJson),
+ "Pretty printed JSON must be displayed");
+
+ // Verify JSON copy into the clipboard.
+ yield waitForClipboardPromise(function setup() {
+ BrowserTestUtils.synthesizeMouseAtCenter(
+ ".textPanelBox .toolbar button.copy",
+ {}, browser);
+ }, function validator(value) {
+ let str = normalizeNewLines(value);
+ return str == prettyJson;
+ });
+});
diff --git a/devtools/client/jsonview/test/browser_jsonview_filter.js b/devtools/client/jsonview/test/browser_jsonview_filter.js
new file mode 100644
index 000000000..5e87bb8ae
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_filter.js
@@ -0,0 +1,28 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "array_json.json";
+
+add_task(function* () {
+ info("Test valid JSON started");
+
+ yield addJsonViewTab(TEST_JSON_URL);
+
+ let count = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
+ is(count, 6, "There must be expected number of rows");
+
+ // XXX use proper shortcut to focus the filter box
+ // as soon as bug Bug 1178771 is fixed.
+ yield sendString("h", ".jsonPanelBox .searchBox");
+
+ // The filtering is done asynchronously so, we need to wait.
+ yield waitForFilter();
+
+ let hiddenCount = yield getElementCount(
+ ".jsonPanelBox .treeTable .treeRow.hidden");
+ is(hiddenCount, 4, "There must be expected number of hidden rows");
+});
diff --git a/devtools/client/jsonview/test/browser_jsonview_invalid_json.js b/devtools/client/jsonview/test/browser_jsonview_invalid_json.js
new file mode 100644
index 000000000..de3cbd74d
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_invalid_json.js
@@ -0,0 +1,20 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "invalid_json.json";
+
+add_task(function* () {
+ info("Test invalid JSON started");
+
+ yield addJsonViewTab(TEST_JSON_URL);
+
+ let count = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
+ ok(count == 0, "There must be no row");
+
+ let text = yield getElementText(".jsonPanelBox .jsonParseError");
+ ok(text, "There must be an error description");
+});
diff --git a/devtools/client/jsonview/test/browser_jsonview_save_json.js b/devtools/client/jsonview/test/browser_jsonview_save_json.js
new file mode 100644
index 000000000..4b95c563f
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_save_json.js
@@ -0,0 +1,38 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "valid_json.json";
+
+let { MockFilePicker } = SpecialPowers;
+
+MockFilePicker.init(window);
+MockFilePicker.returnValue = MockFilePicker.returnCancel;
+
+registerCleanupFunction(function () {
+ MockFilePicker.cleanup();
+});
+
+add_task(function* () {
+ info("Test save JSON started");
+
+ yield addJsonViewTab(TEST_JSON_URL);
+
+ let promise = new Promise((resolve) => {
+ MockFilePicker.showCallback = () => {
+ MockFilePicker.showCallback = null;
+ ok(true, "File picker was opened");
+ resolve();
+ };
+ });
+
+ let browser = gBrowser.selectedBrowser;
+ yield BrowserTestUtils.synthesizeMouseAtCenter(
+ ".jsonPanelBox button.save",
+ {}, browser);
+
+ yield promise;
+});
diff --git a/devtools/client/jsonview/test/browser_jsonview_valid_json.js b/devtools/client/jsonview/test/browser_jsonview_valid_json.js
new file mode 100644
index 000000000..83d0e1088
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_valid_json.js
@@ -0,0 +1,33 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "valid_json.json";
+
+add_task(function* () {
+ info("Test valid JSON started");
+
+ let tab = yield addJsonViewTab(TEST_JSON_URL);
+
+ ok(tab.linkedBrowser.contentPrincipal.isNullPrincipal, "Should have null principal");
+
+ let countBefore = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
+ ok(countBefore == 3, "There must be three rows");
+
+ let objectCellCount = yield getElementCount(
+ ".jsonPanelBox .treeTable .objectCell");
+ ok(objectCellCount == 1, "There must be one object cell");
+
+ let objectCellText = yield getElementText(
+ ".jsonPanelBox .treeTable .objectCell");
+ ok(objectCellText == "", "The summary is hidden when object is expanded");
+
+ // Collapsed auto-expanded node.
+ yield clickJsonNode(".jsonPanelBox .treeTable .treeLabel");
+
+ let countAfter = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
+ ok(countAfter == 1, "There must be one row");
+});
diff --git a/devtools/client/jsonview/test/doc_frame_script.js b/devtools/client/jsonview/test/doc_frame_script.js
new file mode 100644
index 000000000..3d19b3433
--- /dev/null
+++ b/devtools/client/jsonview/test/doc_frame_script.js
@@ -0,0 +1,98 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/* globals Services, sendAsyncMessage, addMessageListener */
+
+// XXX Some helper API could go to:
+// testing/mochitest/tests/SimpleTest/AsyncContentUtils.js
+// (or at least to share test API in devtools)
+
+// Set up a dummy environment so that EventUtils works. We need to be careful to
+// pass a window object into each EventUtils method we call rather than having
+// it rely on the |window| global.
+let EventUtils = {};
+EventUtils.window = content;
+EventUtils.parent = EventUtils.window;
+EventUtils._EU_Ci = Components.interfaces; // eslint-disable-line
+EventUtils._EU_Cc = Components.classes; // eslint-disable-line
+EventUtils.navigator = content.navigator;
+EventUtils.KeyboardEvent = content.KeyboardEvent;
+
+Services.scriptloader.loadSubScript(
+ "chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
+
+/**
+ * When the JSON View is done rendering it triggers custom event
+ * "JSONViewInitialized", then the Test:TestPageProcessingDone message
+ * will be sent to the parent process for tests to wait for this event
+ * if needed.
+ */
+content.addEventListener("JSONViewInitialized", () => {
+ sendAsyncMessage("Test:JsonView:JSONViewInitialized");
+}, false);
+
+addMessageListener("Test:JsonView:GetElementCount", function (msg) {
+ let {selector} = msg.data;
+ let nodeList = content.document.querySelectorAll(selector);
+ sendAsyncMessage(msg.name, {count: nodeList.length});
+});
+
+addMessageListener("Test:JsonView:GetElementText", function (msg) {
+ let {selector} = msg.data;
+ let element = content.document.querySelector(selector);
+ let text = element ? element.textContent : null;
+ sendAsyncMessage(msg.name, {text: text});
+});
+
+addMessageListener("Test:JsonView:FocusElement", function (msg) {
+ let {selector} = msg.data;
+ let element = content.document.querySelector(selector);
+ if (element) {
+ element.focus();
+ }
+ sendAsyncMessage(msg.name);
+});
+
+addMessageListener("Test:JsonView:SendString", function (msg) {
+ let {selector, str} = msg.data;
+ if (selector) {
+ let element = content.document.querySelector(selector);
+ if (element) {
+ element.focus();
+ }
+ }
+
+ EventUtils.sendString(str, content);
+
+ sendAsyncMessage(msg.name);
+});
+
+addMessageListener("Test:JsonView:WaitForFilter", function (msg) {
+ let firstRow = content.document.querySelector(
+ ".jsonPanelBox .treeTable .treeRow");
+
+ // Check if the filter is already set.
+ if (firstRow.classList.contains("hidden")) {
+ sendAsyncMessage(msg.name);
+ return;
+ }
+
+ // Wait till the first row has 'hidden' class set.
+ let observer = new content.MutationObserver(function (mutations) {
+ for (let i = 0; i < mutations.length; i++) {
+ let mutation = mutations[i];
+ if (mutation.attributeName == "class") {
+ if (firstRow.classList.contains("hidden")) {
+ observer.disconnect();
+ sendAsyncMessage(msg.name);
+ break;
+ }
+ }
+ }
+ });
+
+ observer.observe(firstRow, { attributes: true });
+});
diff --git a/devtools/client/jsonview/test/head.js b/devtools/client/jsonview/test/head.js
new file mode 100644
index 000000000..b71883e67
--- /dev/null
+++ b/devtools/client/jsonview/test/head.js
@@ -0,0 +1,145 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint no-unused-vars: [2, {"vars": "local", "args": "none"}] */
+/* import-globals-from ../../framework/test/shared-head.js */
+/* import-globals-from ../../framework/test/head.js */
+
+"use strict";
+
+// shared-head.js handles imports, constants, and utility functions
+Services.scriptloader.loadSubScript(
+ "chrome://mochitests/content/browser/devtools/client/framework/test/head.js", this);
+
+const JSON_VIEW_PREF = "devtools.jsonview.enabled";
+
+// Enable JSON View for the test
+Services.prefs.setBoolPref(JSON_VIEW_PREF, true);
+
+registerCleanupFunction(() => {
+ Services.prefs.clearUserPref(JSON_VIEW_PREF);
+});
+
+// XXX move some API into devtools/framework/test/shared-head.js
+
+/**
+ * Add a new test tab in the browser and load the given url.
+ * @param {String} url The url to be loaded in the new tab
+ * @return a promise that resolves to the tab object when the url is loaded
+ */
+function addJsonViewTab(url) {
+ info("Adding a new JSON tab with URL: '" + url + "'");
+
+ let deferred = promise.defer();
+ addTab(url).then(tab => {
+ let browser = tab.linkedBrowser;
+
+ // Load devtools/shared/frame-script-utils.js
+ getFrameScript();
+
+ // Load frame script with helpers for JSON View tests.
+ let rootDir = getRootDirectory(gTestPath);
+ let frameScriptUrl = rootDir + "doc_frame_script.js";
+ browser.messageManager.loadFrameScript(frameScriptUrl, false);
+
+ // Resolve if the JSONView is fully loaded or wait
+ // for an initialization event.
+ if (content.window.wrappedJSObject.jsonViewInitialized) {
+ deferred.resolve(tab);
+ } else {
+ waitForContentMessage("Test:JsonView:JSONViewInitialized").then(() => {
+ deferred.resolve(tab);
+ });
+ }
+ });
+
+ return deferred.promise;
+}
+
+/**
+ * Expanding a node in the JSON tree
+ */
+function clickJsonNode(selector) {
+ info("Expanding node: '" + selector + "'");
+
+ let browser = gBrowser.selectedBrowser;
+ return BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
+}
+
+/**
+ * Select JSON View tab (in the content).
+ */
+function selectJsonViewContentTab(name) {
+ info("Selecting tab: '" + name + "'");
+
+ let browser = gBrowser.selectedBrowser;
+ let selector = ".tabs-menu .tabs-menu-item." + name + " a";
+ return BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
+}
+
+function getElementCount(selector) {
+ info("Get element count: '" + selector + "'");
+
+ let data = {
+ selector: selector
+ };
+
+ return executeInContent("Test:JsonView:GetElementCount", data)
+ .then(result => {
+ return result.count;
+ });
+}
+
+function getElementText(selector) {
+ info("Get element text: '" + selector + "'");
+
+ let data = {
+ selector: selector
+ };
+
+ return executeInContent("Test:JsonView:GetElementText", data)
+ .then(result => {
+ return result.text;
+ });
+}
+
+function focusElement(selector) {
+ info("Focus element: '" + selector + "'");
+
+ let data = {
+ selector: selector
+ };
+
+ return executeInContent("Test:JsonView:FocusElement", data);
+}
+
+/**
+ * Send the string aStr to the focused element.
+ *
+ * For now this method only works for ASCII characters and emulates the shift
+ * key state on US keyboard layout.
+ */
+function sendString(str, selector) {
+ info("Send string: '" + str + "'");
+
+ let data = {
+ selector: selector,
+ str: str
+ };
+
+ return executeInContent("Test:JsonView:SendString", data);
+}
+
+function waitForTime(delay) {
+ let deferred = promise.defer();
+ setTimeout(deferred.resolve, delay);
+ return deferred.promise;
+}
+
+function waitForFilter() {
+ return executeInContent("Test:JsonView:WaitForFilter");
+}
+
+function normalizeNewLines(value) {
+ return value.replace("(\r\n|\n)", "\n");
+}
diff --git a/devtools/client/jsonview/test/invalid_json.json b/devtools/client/jsonview/test/invalid_json.json
new file mode 100644
index 000000000..004e1e203
--- /dev/null
+++ b/devtools/client/jsonview/test/invalid_json.json
@@ -0,0 +1 @@
+{,}
diff --git a/devtools/client/jsonview/test/invalid_json.json^headers^ b/devtools/client/jsonview/test/invalid_json.json^headers^
new file mode 100644
index 000000000..6010bfd18
--- /dev/null
+++ b/devtools/client/jsonview/test/invalid_json.json^headers^
@@ -0,0 +1 @@
+Content-Type: application/json; charset=utf-8
diff --git a/devtools/client/jsonview/test/simple_json.json b/devtools/client/jsonview/test/simple_json.json
new file mode 100644
index 000000000..831dfbcfb
--- /dev/null
+++ b/devtools/client/jsonview/test/simple_json.json
@@ -0,0 +1 @@
+{"name": "value"}
diff --git a/devtools/client/jsonview/test/simple_json.json^headers^ b/devtools/client/jsonview/test/simple_json.json^headers^
new file mode 100644
index 000000000..6010bfd18
--- /dev/null
+++ b/devtools/client/jsonview/test/simple_json.json^headers^
@@ -0,0 +1 @@
+Content-Type: application/json; charset=utf-8
diff --git a/devtools/client/jsonview/test/valid_json.json b/devtools/client/jsonview/test/valid_json.json
new file mode 100644
index 000000000..ca7356ccd
--- /dev/null
+++ b/devtools/client/jsonview/test/valid_json.json
@@ -0,0 +1,6 @@
+{
+ "family": {
+ "father": "John Doe",
+ "mother": "Alice Doe"
+ }
+}
diff --git a/devtools/client/jsonview/test/valid_json.json^headers^ b/devtools/client/jsonview/test/valid_json.json^headers^
new file mode 100644
index 000000000..6010bfd18
--- /dev/null
+++ b/devtools/client/jsonview/test/valid_json.json^headers^
@@ -0,0 +1 @@
+Content-Type: application/json; charset=utf-8