Bug 1252099 - Main eslint cleanup of markupview tests; r=zer0

MozReview-Commit-ID: FJpdiPUeVcr

--HG--
extra : rebase_source : ecdeff2df26ef39afef5aa6cc33439d91d33fda3
This commit is contained in:
Patrick Brosset 2016-03-03 16:20:03 +01:00
Родитель 1a6943eed5
Коммит c03927677a
53 изменённых файлов: 401 добавлений и 302 удалений

Просмотреть файл

@ -11,7 +11,6 @@ const Events = require("sdk/event/core");
const {ActorClass, Actor, FrontClass, Front, method} =
require("devtools/server/protocol");
const {Cu} = require("chrome");
const {NodeActor} = require("devtools/server/actors/inspector");
var EventsFormActor = ActorClass({

Просмотреть файл

@ -14,17 +14,17 @@ add_task(function*() {
// Markup looks like: <div><::before /><span /><::after /></div>
let children = yield inspector.walker.children(pseudo);
is (children.nodes.length, 3, "Children returned from walker");
is(children.nodes.length, 3, "Children returned from walker");
info ("Checking the ::before pseudo element");
info("Checking the ::before pseudo element");
let before = children.nodes[0];
yield isEditingMenuDisabled(before, inspector);
info ("Checking the normal child element");
info("Checking the normal child element");
let span = children.nodes[1];
yield isEditingMenuEnabled(span, inspector);
info ("Checking the ::after pseudo element");
info("Checking the ::after pseudo element");
let after = children.nodes[2];
yield isEditingMenuDisabled(after, inspector);
@ -32,13 +32,13 @@ add_task(function*() {
// Markup looks like: <div><video controls /></div>
let nativeChildren = yield inspector.walker.children(native);
is (nativeChildren.nodes.length, 1, "Children returned from walker");
is(nativeChildren.nodes.length, 1, "Children returned from walker");
info ("Checking the video element");
info("Checking the video element");
let video = nativeChildren.nodes[0];
ok (!video.isAnonymous, "<video> is not anonymous");
ok(!video.isAnonymous, "<video> is not anonymous");
let videoChildren = yield inspector.walker.children(video);
is (videoChildren.nodes.length, 0,
is(videoChildren.nodes.length, 0,
"No native children returned from walker for <video> by default");
});

Просмотреть файл

@ -16,16 +16,16 @@ add_task(function*() {
let children = yield inspector.walker.children(toolbarbutton);
is(toolbarbutton.numChildren, 3, "Correct number of children");
is (children.nodes.length, 3, "Children returned from walker");
is(children.nodes.length, 3, "Children returned from walker");
is(toolbarbutton.isAnonymous, false, "Toolbarbutton is not anonymous");
yield isEditingMenuEnabled(toolbarbutton, inspector);
for (let node of children.nodes) {
ok (node.isAnonymous, "Child is anonymous");
ok (node._form.isXBLAnonymous, "Child is XBL anonymous");
ok (!node._form.isShadowAnonymous, "Child is not shadow anonymous");
ok (!node._form.isNativeAnonymous, "Child is not native anonymous");
ok(node.isAnonymous, "Child is anonymous");
ok(node._form.isXBLAnonymous, "Child is XBL anonymous");
ok(!node._form.isShadowAnonymous, "Child is not shadow anonymous");
ok(!node._form.isNativeAnonymous, "Child is not native anonymous");
yield isEditingMenuDisabled(node, inspector);
}
});

Просмотреть файл

@ -17,18 +17,18 @@ add_task(function*() {
let shadow = yield getNodeFront("#shadow", inspector.markup);
let children = yield inspector.walker.children(shadow);
is (shadow.numChildren, 3, "Children of the shadow root are counted");
is (children.nodes.length, 3, "Children returned from walker");
is(shadow.numChildren, 3, "Children of the shadow root are counted");
is(children.nodes.length, 3, "Children returned from walker");
info ("Checking the ::before pseudo element");
info("Checking the ::before pseudo element");
let before = children.nodes[0];
yield isEditingMenuDisabled(before, inspector);
info ("Checking the <h3> shadow element");
info("Checking the <h3> shadow element");
let shadowChild1 = children.nodes[1];
yield isEditingMenuDisabled(shadowChild1, inspector);
info ("Checking the <select> shadow element");
info("Checking the <select> shadow element");
let shadowChild2 = children.nodes[2];
yield isEditingMenuDisabled(shadowChild2, inspector);
});

Просмотреть файл

@ -4,12 +4,13 @@
"use strict";
// Test native anonymous content in the markupview with devtools.inspector.showAllAnonymousContent
// set to true
// Test native anonymous content in the markupview with
// devtools.inspector.showAllAnonymousContent set to true
const TEST_URL = URL_ROOT + "doc_markup_anonymous.html";
const PREF = "devtools.inspector.showAllAnonymousContent";
add_task(function*() {
Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true);
Services.prefs.setBoolPref(PREF, true);
let {inspector} = yield openInspectorForURL(TEST_URL);
@ -17,20 +18,20 @@ add_task(function*() {
// Markup looks like: <div><video controls /></div>
let nativeChildren = yield inspector.walker.children(native);
is (nativeChildren.nodes.length, 1, "Children returned from walker");
is(nativeChildren.nodes.length, 1, "Children returned from walker");
info ("Checking the video element");
info("Checking the video element");
let video = nativeChildren.nodes[0];
ok (!video.isAnonymous, "<video> is not anonymous");
ok(!video.isAnonymous, "<video> is not anonymous");
let videoChildren = yield inspector.walker.children(video);
is (videoChildren.nodes.length, 3, "<video> has native anonymous children");
is(videoChildren.nodes.length, 3, "<video> has native anonymous children");
for (let node of videoChildren.nodes) {
ok (node.isAnonymous, "Child is anonymous");
ok (!node._form.isXBLAnonymous, "Child is not XBL anonymous");
ok (!node._form.isShadowAnonymous, "Child is not shadow anonymous");
ok (node._form.isNativeAnonymous, "Child is native anonymous");
ok(node.isAnonymous, "Child is anonymous");
ok(!node._form.isXBLAnonymous, "Child is not XBL anonymous");
ok(!node._form.isShadowAnonymous, "Child is not shadow anonymous");
ok(node._form.isNativeAnonymous, "Child is native anonymous");
yield isEditingMenuDisabled(node, inspector);
}
});

Просмотреть файл

@ -22,45 +22,49 @@ const TEST_URL = URL_ROOT + "doc_markup_edit.html";
// is popup expected to be open ?
// ]
const TEST_DATA = [
['s', 's', 1, 1, false],
['t', 'st', 2, 2, false],
['y', 'sty', 3, 3, false],
['l', 'styl', 4, 4, false],
['e', 'style', 5, 5, false],
['=', 'style=', 6, 6, false],
['"', 'style="', 7, 7, false],
['d', 'style="direction', 8, 16, true],
['VK_DOWN', 'style="display', 8, 14, true],
['VK_TAB', 'style="display', 14, 14, true],
['VK_TAB', 'style="dominant-baseline', 24, 24, true],
['VK_TAB', 'style="direction', 16, 16, true],
['click_1', 'style="display', 14, 14, false],
[':', 'style="display:-moz-box', 15, 23, true],
['n', 'style="display:none', 16, 19, false],
['VK_BACK_SPACE', 'style="display:n', 16, 16, false],
['VK_BACK_SPACE', 'style="display:', 15, 15, false],
[' ', 'style="display: -moz-box', 16, 24, true],
[' ', 'style="display: -moz-box', 17, 25, true],
['i', 'style="display: inherit', 18, 24, true],
['VK_RIGHT', 'style="display: inherit', 24, 24, false],
[';', 'style="display: inherit;', 25, 25, false],
[' ', 'style="display: inherit; ', 26, 26, false],
[' ', 'style="display: inherit; ', 27, 27, false],
['VK_LEFT', 'style="display: inherit; ', 26, 26, false],
['c', 'style="display: inherit; caption-side ', 27, 38, true],
['o', 'style="display: inherit; color ', 28, 31, true],
['VK_RIGHT', 'style="display: inherit; color ', 31, 31, false],
[' ', 'style="display: inherit; color ', 32, 32, false],
['c', 'style="display: inherit; color c ', 33, 33, false],
['VK_BACK_SPACE', 'style="display: inherit; color ', 32, 32, false],
[':', 'style="display: inherit; color :aliceblue ', 33, 42, true],
['c', 'style="display: inherit; color :cadetblue ', 34, 42, true],
['VK_DOWN', 'style="display: inherit; color :chartreuse ', 34, 43, true],
['VK_RIGHT', 'style="display: inherit; color :chartreuse ', 43, 43, false],
[' ', 'style="display: inherit; color :chartreuse !important; ', 44, 55, true],
['!', 'style="display: inherit; color :chartreuse !important; ', 45, 55, false],
['VK_RIGHT', 'style="display: inherit; color :chartreuse !important; ', 55, 55, false],
['VK_RETURN', 'style="display: inherit; color :chartreuse !important;"', -1, -1, false]
["s", "s", 1, 1, false],
["t", "st", 2, 2, false],
["y", "sty", 3, 3, false],
["l", "styl", 4, 4, false],
["e", "style", 5, 5, false],
["=", "style=", 6, 6, false],
["\"", "style=\"", 7, 7, false],
["d", "style=\"direction", 8, 16, true],
["VK_DOWN", "style=\"display", 8, 14, true],
["VK_TAB", "style=\"display", 14, 14, true],
["VK_TAB", "style=\"dominant-baseline", 24, 24, true],
["VK_TAB", "style=\"direction", 16, 16, true],
["click_1", "style=\"display", 14, 14, false],
[":", "style=\"display:-moz-box", 15, 23, true],
["n", "style=\"display:none", 16, 19, false],
["VK_BACK_SPACE", "style=\"display:n", 16, 16, false],
["VK_BACK_SPACE", "style=\"display:", 15, 15, false],
[" ", "style=\"display: -moz-box", 16, 24, true],
[" ", "style=\"display: -moz-box", 17, 25, true],
["i", "style=\"display: inherit", 18, 24, true],
["VK_RIGHT", "style=\"display: inherit", 24, 24, false],
[";", "style=\"display: inherit;", 25, 25, false],
[" ", "style=\"display: inherit; ", 26, 26, false],
[" ", "style=\"display: inherit; ", 27, 27, false],
["VK_LEFT", "style=\"display: inherit; ", 26, 26, false],
["c", "style=\"display: inherit; caption-side ", 27, 38, true],
["o", "style=\"display: inherit; color ", 28, 31, true],
["VK_RIGHT", "style=\"display: inherit; color ", 31, 31, false],
[" ", "style=\"display: inherit; color ", 32, 32, false],
["c", "style=\"display: inherit; color c ", 33, 33, false],
["VK_BACK_SPACE", "style=\"display: inherit; color ", 32, 32, false],
[":", "style=\"display: inherit; color :aliceblue ", 33, 42, true],
["c", "style=\"display: inherit; color :cadetblue ", 34, 42, true],
["VK_DOWN", "style=\"display: inherit; color :chartreuse ", 34, 43, true],
["VK_RIGHT", "style=\"display: inherit; color :chartreuse ", 43, 43, false],
[" ", "style=\"display: inherit; color :chartreuse !important; ",
44, 55, true],
["!", "style=\"display: inherit; color :chartreuse !important; ",
45, 55, false],
["VK_RIGHT", "style=\"display: inherit; color :chartreuse !important; ",
55, 55, false],
["VK_RETURN", "style=\"display: inherit; color :chartreuse !important;\"",
-1, -1, false]
];
add_task(function*() {
@ -97,7 +101,8 @@ add_task(function*() {
function enterData(index, editor, inspector) {
let [key] = TEST_DATA[index];
info("Entering test data " + index + ": " + key + ", expecting: [" + TEST_DATA[index].slice(1) + "]");
let expected = TEST_DATA[index].slice(1);
info(`Entering test data ${index}: ${key}, expecting: [${expected}]`);
let def = promise.defer();
@ -131,23 +136,26 @@ function enterData(index, editor, inspector) {
}
function* checkData(index, editor, inspector) {
let [key, completion, selStart, selEnd, popupOpen] = TEST_DATA[index];
let [, completion, selStart, selEnd, popupOpen] = TEST_DATA[index];
info("Test data " + index + " entered. Checking state.");
if (selEnd != -1) {
is(editor.input.value, completion, "Completed value is correct");
is(editor.input.selectionStart, selStart, "Selection start position is correct");
is(editor.input.selectionStart, selStart,
"Selection start position is correct");
is(editor.input.selectionEnd, selEnd, "Selection end position is correct");
if (popupOpen) {
ok(editor.popup.isOpen, "Popup is open");
} else {
ok(editor.popup._panel.state != "open" && editor.popup._panel.state != "showing",
ok(editor.popup._panel.state != "open" &&
editor.popup._panel.state != "showing",
"Popup is closed");
}
} else {
let nodeFront = yield getNodeFront("#node14", inspector);
let editor = getContainerForNodeFront(nodeFront, inspector).editor;
let attr = editor.attrElements.get("style").querySelector(".editable");
is(attr.textContent, completion, "Correct value is persisted after pressing Enter");
is(attr.textContent, completion,
"Correct value is persisted after pressing Enter");
}
}

Просмотреть файл

@ -7,9 +7,10 @@
// Check that pseudo-elements and anonymous nodes are not draggable.
const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html";
const PREF = "devtools.inspector.showAllAnonymousContent";
add_task(function*() {
Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true);
Services.prefs.setBoolPref(PREF, true);
let {inspector} = yield openInspectorForURL(TEST_URL);

Просмотреть файл

@ -1,3 +1,6 @@
/* 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";
// Test that tooltips don't appear when dragging over tooltip targets.
@ -20,10 +23,10 @@ add_task(function*() {
yield simulateNodeDrag(inspector, "div");
info("Now check that the src attribute of the image isn't a valid target");
try{
try {
yield markup.tooltip.isValidHoverTarget(target);
isValid = true;
} catch(e) {
} catch (e) {
isValid = false;
}
ok(!isValid, "The element is not a valid tooltip target");

Просмотреть файл

@ -7,8 +7,10 @@ const TEST_URL = URL_ROOT + "doc_markup_events-overflow.html";
const TEST_DATA = [
{
desc: "editor overflows container",
initialScrollTop: -1, // scroll to bottom
headerToClick: 49, // last header
// scroll to bottom
initialScrollTop: -1,
// last header
headerToClick: 49,
alignBottom: true,
alignTop: false,
},
@ -36,7 +38,8 @@ add_task(function*() {
let tooltip = inspector.markup.tooltip;
info("Clicking to open event tooltip.");
EventUtils.synthesizeMouseAtCenter(evHolder, {}, inspector.markup.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(evHolder, {},
inspector.markup.doc.defaultView);
yield tooltip.once("shown");
info("EventTooltip visible.");
@ -75,13 +78,11 @@ add_task(function*() {
is(Math.round(headerRect.top), Math.round(containerRect.top),
"Clicked header is aligned with the container top.");
} else if (data.alignBottom) {
let editorRect = header.nextElementSibling.getBoundingClientRect();
is(Math.round(editorRect.bottom), Math.round(containerRect.bottom),
"Clicked event handler code is aligned with the container bottom.");
} else {
is(container.scrollTop, data.initialScrollTop,
"Container did not scroll, as expected.");

Просмотреть файл

@ -1,6 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
@ -11,7 +12,7 @@ const TEST_URL = URL_ROOT + "doc_markup_events.html";
loadHelperScript("helper_events_test_runner.js");
const TEST_DATA = [
const TEST_DATA = [ // eslint-disable-line
{
selector: "html",
expected: [
@ -36,12 +37,12 @@ const TEST_DATA = [
"Capturing",
"DOM2"
],
handler: 'function mouseoverHandler(event) {\n' +
' if (event.target.id !== "container") {\n' +
' let output = document.getElementById("output");\n' +
' output.textContent = event.target.textContent;\n' +
' }\n' +
'}'
handler: "function mouseoverHandler(event) {\n" +
" if (event.target.id !== \"container\") {\n" +
" let output = document.getElementById(\"output\");\n" +
" output.textContent = event.target.textContent;\n" +
" }\n" +
"}"
}
]
},
@ -55,10 +56,10 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'function clickHandler(event) {\n' +
' let output = document.getElementById("output");\n' +
' output.textContent = "click";\n' +
'}'
handler: "function clickHandler(event) {\n" +
" let output = document.getElementById(\"output\");\n" +
" output.textContent = \"click\";\n" +
"}"
},
{
type: "mouseup",
@ -67,10 +68,10 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'function mouseupHandler(event) {\n' +
' let output = document.getElementById("output");\n' +
' output.textContent = "mouseup";\n' +
'}'
handler: "function mouseupHandler(event) {\n" +
" let output = document.getElementById(\"output\");\n" +
" output.textContent = \"mouseup\";\n" +
"}"
}
]
},
@ -98,9 +99,9 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'handleEvent: function(blah) {\n' +
' alert("handleEvent clicked");\n' +
'}'
handler: "handleEvent: function(blah) {\n" +
" alert(\"handleEvent clicked\");\n" +
"}"
}
]
},
@ -114,9 +115,9 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'event => {\n' +
' alert("Yay for the fat arrow!");\n' +
'}'
handler: "event => {\n" +
" alert(\"Yay for the fat arrow!\");\n" +
"}"
}
]
},
@ -130,9 +131,9 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'handleEvent: function() {\n' +
' alert("boundHandleEvent clicked");\n' +
'}'
handler: "handleEvent: function() {\n" +
" alert(\"boundHandleEvent clicked\");\n" +
"}"
}
]
},
@ -146,9 +147,9 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'function boundClickHandler(event) {\n' +
' alert("Bound event clicked");\n' +
'}'
handler: "function boundClickHandler(event) {\n" +
" alert(\"Bound event clicked\");\n" +
"}"
}
]
},
@ -173,9 +174,9 @@ const TEST_DATA = [
"Bubbling",
"DOM2"
],
handler: 'function noeventsClickHandler(event) {\n' +
' alert("noevents has an event listener");\n' +
'}'
handler: "function noeventsClickHandler(event) {\n" +
" alert(\"noevents has an event listener\");\n" +
"}"
}
]
},
@ -183,11 +184,14 @@ const TEST_DATA = [
selector: "#noevents",
beforeTest: function* (inspector, testActor) {
let nodeMutated = inspector.once("markupmutation");
yield testActor.eval("window.wrappedJSObject.removeNoeventsClickHandler();");
yield testActor.eval(
"window.wrappedJSObject.removeNoeventsClickHandler();");
yield nodeMutated;
},
expected: []
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -12,7 +12,6 @@
const TEST_PAGE_URL = URL_ROOT + "doc_markup_events_form.html";
const TEST_ACTOR_URL = CHROME_URL_ROOT + "actor_events_form.js";
var {ActorRegistryFront} = require("devtools/server/actors/actor-registry");
var {EventsFormFront} = require(TEST_ACTOR_URL);
add_task(function*() {

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
// Test that markup view event bubbles show the correct event info for jQuery
@ -231,4 +231,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
// Test that markup view event bubbles show the correct event info for jQuery
@ -265,4 +265,6 @@ const TEST_DATA = [
}
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
// Test that markup view event bubbles show the correct event info for jQuery
@ -189,4 +189,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
// Test that markup view event bubbles show the correct event info for jQuery
@ -184,4 +184,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
// Test that markup view event bubbles show the correct event info for jQuery
@ -217,4 +217,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
// Test that markup view event bubbles show the correct event info for jQuery
@ -280,4 +280,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
requestLongerTimeout(2);
@ -381,4 +381,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
requestLongerTimeout(2);
@ -227,4 +227,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_events_test_runner.js */
"use strict";
requestLongerTimeout(2);
@ -189,4 +189,6 @@ const TEST_DATA = [
},
];
add_task(runEventPopupTests);
add_task(function*() {
yield runEventPopupTests(TEST_URL, TEST_DATA);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_outerhtml_test_runner.js */
"use strict";
// Test outerHTML edition via the markup-view

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_outerhtml_test_runner.js */
"use strict";
// Test outerHTML edition via the markup-view

Просмотреть файл

@ -29,7 +29,8 @@ add_task(function*() {
let container = getContainerForNodeFront(img, inspector);
ok(container, "Found markup container for the image.");
let target = container.editor.getAttributeElement("src").querySelector(".link");
let target = container.editor.getAttributeElement("src")
.querySelector(".link");
ok(target, "Found the src attribute in the markup view.");
info("Showing tooltip on the src link.");

Просмотреть файл

@ -8,10 +8,11 @@
// the first focusable element in the corresponding MarkupContainer so that the
// keyboard can be used immediately.
const TEST_URL = "data:text/html;charset=utf8,<div class='test-class'></div>Text node";
const TEST_URL = `data:text/html;charset=utf8,
<div class='test-class'></div>Text node`;
add_task(function*() {
let {inspector, toolbox} = yield openInspectorForURL(TEST_URL);
let {inspector} = yield openInspectorForURL(TEST_URL);
let {walker} = inspector;
info("Select the test node to have the 2 test containers visible");
@ -34,7 +35,8 @@ add_task(function*() {
info("Click on the test-class attribute, to make sure it gets focused");
let editor = getContainerForNodeFront(divFront, inspector).editor;
let attributeEditor = editor.attrElements.get("class").querySelector(".editable");
let attributeEditor = editor.attrElements.get("class")
.querySelector(".editable");
let onFocus = once(attributeEditor, "focus");
EventUtils.synthesizeMouseAtCenter(attributeEditor, {type: "mousedown"},

Просмотреть файл

@ -111,13 +111,16 @@ add_task(function*() {
for (let {attributeName, links} of attributes) {
info("Testing attribute " + attributeName);
let linkEls = editor.attrElements.get(attributeName).querySelectorAll(".link");
let linkEls = editor.attrElements.get(attributeName)
.querySelectorAll(".link");
is(linkEls.length, links.length, "The right number of links were found");
for (let i = 0; i < links.length; i ++) {
is(linkEls[i].dataset.type, links[i].type, "Link " + i + " has the right type");
is(linkEls[i].textContent, links[i].value, "Link " + i + " has the right value");
for (let i = 0; i < links.length; i++) {
is(linkEls[i].dataset.type, links[i].type,
`Link ${i} has the right type`);
is(linkEls[i].textContent, links[i].value,
`Link ${i} has the right value`);
}
}
}

Просмотреть файл

@ -17,7 +17,8 @@ add_task(function*() {
info("Checking for links in the new attribute");
let {editor} = yield getContainerForSelector("body", inspector);
let linkEls = editor.attrElements.get("contextmenu").querySelectorAll(".link");
let linkEls = editor.attrElements.get("contextmenu")
.querySelectorAll(".link");
is(linkEls.length, 1, "There is one link in the contextmenu attribute");
is(linkEls[0].dataset.type, "idref", "The link has the right type");
is(linkEls[0].textContent, "menu1", "The link has the right value");

Просмотреть файл

@ -18,7 +18,8 @@ add_task(function*() {
info("Checking for links in the new attribute");
let {editor} = yield getContainerForSelector("body", inspector);
let linkEls = editor.attrElements.get("contextmenu").querySelectorAll(".link");
let linkEls = editor.attrElements.get("contextmenu")
.querySelectorAll(".link");
is(linkEls.length, 1, "There is one link in the contextmenu attribute");
is(linkEls[0].dataset.type, "idref", "The link has the right type");
is(linkEls[0].textContent, "menu1", "The link has the right value");

Просмотреть файл

@ -28,16 +28,20 @@ const TEST_DATA = [{
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: true,
linkFollowItemLabel: TOOLBOX_STRINGS.GetStringFromName("toolbox.viewCssSourceInStyleEditor.label"),
linkCopyItemLabel: STRINGS.GetStringFromName("inspector.menu.copyUrlToClipboard.label")
linkFollowItemLabel: TOOLBOX_STRINGS.GetStringFromName(
"toolbox.viewCssSourceInStyleEditor.label"),
linkCopyItemLabel: STRINGS.GetStringFromName(
"inspector.menu.copyUrlToClipboard.label")
}, {
selector: "link[rel=icon]",
attributeName: "href",
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: true,
linkFollowItemLabel: STRINGS.GetStringFromName("inspector.menu.openUrlInNewTab.label"),
linkCopyItemLabel: STRINGS.GetStringFromName("inspector.menu.copyUrlToClipboard.label")
linkFollowItemLabel: STRINGS.GetStringFromName(
"inspector.menu.openUrlInNewTab.label"),
linkCopyItemLabel: STRINGS.GetStringFromName(
"inspector.menu.copyUrlToClipboard.label")
}, {
selector: "link",
attributeName: "rel",
@ -58,8 +62,10 @@ const TEST_DATA = [{
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: true,
linkFollowItemLabel: TOOLBOX_STRINGS.GetStringFromName("toolbox.viewJsSourceInDebugger.label"),
linkCopyItemLabel: STRINGS.GetStringFromName("inspector.menu.copyUrlToClipboard.label")
linkFollowItemLabel: TOOLBOX_STRINGS.GetStringFromName(
"toolbox.viewJsSourceInDebugger.label"),
linkCopyItemLabel: STRINGS.GetStringFromName(
"inspector.menu.copyUrlToClipboard.label")
}, {
selector: "p[for]",
attributeName: "for",

Просмотреть файл

@ -37,7 +37,8 @@ add_task(function*() {
info("Follow link with middle-click, wait for new node to be selected.");
yield followLinkWaitForNewNode(linkEl, false, inspector);
// We have to re-select the label as the link switched the currently selected node
// We have to re-select the label as the link switched the currently selected
// node.
yield selectNode("label", inspector);
info("Follow link with ctrl/meta-click, wait for new node to be selected.");

Просмотреть файл

@ -13,7 +13,7 @@ const server = createTestHTTPServer();
// Register a slow image handler so we can simulate a long time between
// a reload and the load event firing.
server.registerContentType("gif", "image/gif");
server.registerPathHandler("/slow.gif", function (metadata, response) {
server.registerPathHandler("/slow.gif", function(metadata, response) {
info("Image has been requested");
response.processAsync();
setTimeout(() => {

Просмотреть файл

@ -103,8 +103,8 @@ const TEST_DATA = [
ok(container.singleTextChild, "Has single text child.");
ok(!container.canExpand, "Can't expand container with singleTextChild.");
ok(!container.singleTextChild.canExpand, "Can't expand singleTextChild.");
is(container.editor.elt.querySelector(".text").textContent.trim(), "newtext",
"Single text child editor updated.");
is(container.editor.elt.querySelector(".text").textContent.trim(),
"newtext", "Single text child editor updated.");
}
},
{
@ -133,8 +133,8 @@ const TEST_DATA = [
ok(container.singleTextChild, "Has single text child.");
ok(!container.canExpand, "Can't expand container with singleTextChild.");
ok(!container.singleTextChild.canExpand, "Can't expand singleTextChild.");
ok(container.editor.elt.querySelector(".text").textContent.trim(), "newtext",
"Single text child editor updated.");
ok(container.editor.elt.querySelector(".text").textContent.trim(),
"newtext", "Single text child editor updated.");
},
},
{
@ -162,8 +162,8 @@ const TEST_DATA = [
ok(container.singleTextChild, "Has single text child.");
ok(!container.canExpand, "Can't expand container with singleTextChild.");
ok(!container.singleTextChild.canExpand, "Can't expand singleTextChild.");
ok(container.editor.elt.querySelector(".text").textContent.trim(), "newtext",
"Single text child editor updated.");
ok(container.editor.elt.querySelector(".text").textContent.trim(),
"newtext", "Single text child editor updated.");
},
},
@ -207,7 +207,8 @@ const TEST_DATA = [
},
check: function*(inspector) {
let {children} = yield getContainerForSelector("#node16", inspector);
is(children.innerHTML, "", "Node17 has been removed from its node16 parent");
is(children.innerHTML, "",
"Node17 has been removed from its node16 parent");
let container = yield getContainerForSelector("#node2", inspector);
let openTags = container.children.querySelectorAll(".open .tag");
@ -252,18 +253,19 @@ const TEST_DATA = [
"Node20 has 2 children (21 and 18)");
let node21 = node20Children.childNodes[0];
is(node21.container.editor.elt.querySelector(".text").textContent.trim(), "line21",
"Node21 has a single text child");
is(node21.container.editor.elt.querySelector(".text").textContent.trim(),
"line21", "Node21 has a single text child");
let node18 = node20Children.childNodes[1];
is(node18.querySelector(".open .attreditor .attr-value").textContent.trim(),
"node18", "Node20's second child is indeed node18");
is(node18.querySelector(".open .attreditor .attr-value")
.textContent.trim(),
"node18", "Node20's second child is indeed node18");
}
}
];
add_task(function*() {
let {toolbox, inspector} = yield openInspectorForURL(TEST_URL);
let {inspector} = yield openInspectorForURL(TEST_URL);
info("Expanding all markup-view nodes");
yield inspector.markup.expandAll();
@ -289,7 +291,7 @@ add_task(function*() {
});
test();
})
});
info("Expanding all markup-view nodes to make sure new nodes are imported");
yield inspector.markup.expandAll();

Просмотреть файл

@ -7,14 +7,15 @@
// Test that markup-containers in the markup-view do flash when their
// corresponding DOM nodes mutate
const {clearTimeout} = require("sdk/timers");
const TEST_URL = URL_ROOT + "doc_markup_flashing.html";
// The test data contains a list of mutations to test.
// Each item is an object:
// - desc: a description of the test step, for better logging
// - mutate: a function that should make changes to the content DOM
// - attribute: if set, the test will expect the corresponding attribute to flash
// instead of the whole node
// - attribute: if set, the test will expect the corresponding attribute to
// flash instead of the whole node
// - flashedNode: [optional] the css selector of the node that is expected to
// flash in the markup-view as a result of the mutation.
// If missing, the rootNode (".list") will be expected to flash
@ -44,7 +45,8 @@ const TEST_DATA = [{
rootNode.setAttribute("test-name", "value-" + Date.now());
}
}, {
desc: "Adding an attribute with css reserved characters should flash the attribute",
desc: "Adding an attribute with css reserved characters should flash the " +
"attribute",
attribute: "one:two",
mutate: (doc, rootNode) => {
rootNode.setAttribute("one:two", "value-" + Date.now());
@ -115,8 +117,8 @@ function* assertNodeFlashing(nodeFront, inspector) {
ok(container.tagState.classList.contains("theme-bg-contrast"),
"Markup container for node is flashing");
// Clear the mutation flashing timeout now that we checked the node was flashing
let markup = inspector.markup;
// Clear the mutation flashing timeout now that we checked the node was
// flashing.
clearTimeout(container._flashMutationTimer);
container._flashMutationTimer = null;
container.tagState.classList.remove("theme-bg-contrast");
@ -125,7 +127,8 @@ function* assertNodeFlashing(nodeFront, inspector) {
function* assertAttributeFlashing(nodeFront, attribute, inspector) {
let container = getContainerForNodeFront(nodeFront, inspector);
ok(container, "Markup container for node found");
ok(container.editor.attrElements.get(attribute), "Attribute exists on editor");
ok(container.editor.attrElements.get(attribute),
"Attribute exists on editor");
let attributeElement = container.editor.getAttributeElement(attribute);

Просмотреть файл

@ -29,6 +29,6 @@ add_task(function*() {
let nodeFront = yield getNodeFront(selector, inspector);
let container = getContainerForNodeFront(nodeFront, inspector);
is(!container.elt.classList.contains("not-displayed"), isDisplayed,
"The container for " + selector + " is marked as displayed " + isDisplayed);
`The container for ${selector} is marked as displayed ${isDisplayed}`);
}
});

Просмотреть файл

@ -5,8 +5,8 @@
"use strict";
// Tests that the markup view loads only as many nodes as specified
// by the devtools.markup.pagesize preference and that pressing the "show all nodes"
// actually shows the nodes
// by the devtools.markup.pagesize preference and that pressing the "show all
// nodes" actually shows the nodes
const TEST_URL = URL_ROOT + "doc_markup_pagesize_02.html";
@ -40,6 +40,7 @@ function* showAllNodes(inspector) {
function* assertAllNodesAreVisible(inspector) {
let container = yield getContainerForSelector("ul", inspector);
ok(!container.elt.querySelector("button"), "All nodes button isn't here anymore");
ok(!container.elt.querySelector("button"),
"All nodes button isn't here anymore");
is(container.children.childNodes.length, getNode("ul").children.length);
}

Просмотреть файл

@ -15,7 +15,8 @@ add_task(function*() {
let panel = yield getNode("#test", inspector);
let panelFront = yield getNodeFront("#test", inspector);
ok(panelFront.hasAttribute("id"), "panelFront has id attribute in the beginning");
ok(panelFront.hasAttribute("id"),
"panelFront has id attribute in the beginning");
info("Removing panel's id attribute");
panel.removeAttribute("id");
@ -23,5 +24,6 @@ add_task(function*() {
info("Waiting for markupmutation");
yield inspector.once("markupmutation");
is(panelFront.hasAttribute("id"), false, "panelFront doesn't have id attribute anymore");
is(panelFront.hasAttribute("id"), false,
"panelFront doesn't have id attribute anymore");
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_attributes_test_runner.js */
"use strict";
// Test editing various markup-containers' attribute fields
@ -23,8 +23,8 @@ var TEST_DATA = [{
class: "changednode1"
}
}, {
desc: 'Try changing an attribute to a quote (") - this should result ' +
'in it being set to an empty string',
desc: "Try changing an attribute to a quote (\") - this should result " +
"in it being set to an empty string",
node: "#node22",
originalAttributes: {
id: "node22",

Просмотреть файл

@ -6,7 +6,8 @@
// Tests that an existing attribute can be modified
const TEST_URL = "data:text/html,<div id='test-div'>Test modifying my ID attribute</div>";
const TEST_URL = `data:text/html,
<div id='test-div'>Test modifying my ID attribute</div>`;
add_task(function*() {
info("Opening the inspector on the test page");

Просмотреть файл

@ -6,7 +6,8 @@
// Tests that a node's tagname can be edited in the markup-view
const TEST_URL = "data:text/html;charset=utf-8,<div id='retag-me'><div id='retag-me-2'></div></div>";
const TEST_URL = `data:text/html;charset=utf-8,
<div id='retag-me'><div id='retag-me-2'></div></div>`;
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_attributes_test_runner.js */
"use strict";
// Tests that adding various types of attributes to nodes in the markup-view
@ -61,17 +61,17 @@ var TEST_DATA = [{
disabled: "",
autofocus: "",
name: "name",
'data-test': "test"
"data-test": "test"
}
}, {
desc: "Add attribute with xmlns",
text: "xmlns:edi='http://ecommerce.example.org/schema'",
expectedAttributes: {
'xmlns:edi': "http://ecommerce.example.org/schema"
"xmlns:edi": "http://ecommerce.example.org/schema"
}
}];
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor)
yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_attributes_test_runner.js */
"use strict";
// Tests that adding various types of attributes to nodes in the markup-view
@ -71,7 +71,8 @@ var TEST_DATA = [{
}
}, {
desc: "Add event handlers",
text: "onclick=\"javascript: throw new Error('wont fire');\" onload=\"alert('here');\"",
text: "onclick=\"javascript: throw new Error('wont fire');\" " +
"onload=\"alert('here');\"",
expectedAttributes: {
onclick: "javascript: throw new Error('wont fire');",
onload: "alert('here');"
@ -80,5 +81,5 @@ var TEST_DATA = [{
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor)
yield runAddAttributesTests(TEST_DATA, "div", inspector, testActor);
});

Просмотреть файл

@ -1,7 +1,7 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_attributes_test_runner.js */
"use strict";
// One more test testing various add-attributes configurations
@ -31,9 +31,9 @@ var TEST_DATA = [{
style: "color:green"
}
}, {
desc: 'Try add an attribute containing a quote (") attribute by ' +
'clicking the empty space after a node - this should result ' +
'in it being set to an empty string',
desc: "Try add an attribute containing a quote (\") attribute by " +
"clicking the empty space after a node - this should result " +
"in it being set to an empty string",
text: 'class="newclass" style="""',
expectedAttributes: {
class: "newclass",
@ -41,41 +41,46 @@ var TEST_DATA = [{
}
}, {
desc: "Try to add long data URL to make sure it is collapsed in attribute editor.",
text: "style='"+DATA_URL_INLINE_STYLE+"'",
text: `style='${DATA_URL_INLINE_STYLE}'`,
expectedAttributes: {
'style': DATA_URL_INLINE_STYLE
"style": DATA_URL_INLINE_STYLE
},
validate: (element, container, inspector) => {
let editor = container.editor;
let visibleAttrText = editor.attrElements.get("style").querySelector(".attr-value").textContent;
is (visibleAttrText, DATA_URL_INLINE_STYLE_COLLAPSED);
let visibleAttrText = editor.attrElements.get("style")
.querySelector(".attr-value")
.textContent;
is(visibleAttrText, DATA_URL_INLINE_STYLE_COLLAPSED);
}
}, {
desc: "Try to add long attribute to make sure it is collapsed in attribute editor.",
text: 'data-long="'+LONG_ATTRIBUTE+'"',
text: `data-long="${LONG_ATTRIBUTE}"`,
expectedAttributes: {
'data-long':LONG_ATTRIBUTE
"data-long": LONG_ATTRIBUTE
},
validate: (element, container, inspector) => {
let editor = container.editor;
let visibleAttrText = editor.attrElements.get("data-long").querySelector(".attr-value").textContent;
is (visibleAttrText, LONG_ATTRIBUTE_COLLAPSED)
let visibleAttrText = editor.attrElements.get("data-long")
.querySelector(".attr-value")
.textContent;
is(visibleAttrText, LONG_ATTRIBUTE_COLLAPSED);
}
}, {
desc: "Try to add long data URL to make sure it is collapsed in attribute editor.",
text: 'src="'+DATA_URL_ATTRIBUTE+'"',
text: `src="${DATA_URL_ATTRIBUTE}"`,
expectedAttributes: {
"src": DATA_URL_ATTRIBUTE
},
validate: (element, container, inspector) => {
let editor = container.editor;
let visibleAttrText = editor.attrElements.get("src").querySelector(".attr-value").textContent;
is (visibleAttrText, DATA_URL_ATTRIBUTE_COLLAPSED);
let visibleAttrText = editor.attrElements.get("src")
.querySelector(".attr-value").textContent;
is(visibleAttrText, DATA_URL_ATTRIBUTE_COLLAPSED);
}
}, {
desc: "Try to add long attribute with collapseAttributes == false" +
"to make sure it isn't collapsed in attribute editor.",
text: 'data-long="' + LONG_ATTRIBUTE + '"',
text: `data-long="${LONG_ATTRIBUTE}"`,
expectedAttributes: {
"data-long": LONG_ATTRIBUTE
},
@ -95,7 +100,7 @@ var TEST_DATA = [{
}
}, {
desc: "Try to collapse attributes with collapseAttributeLength == 5",
text: 'data-long="' + LONG_ATTRIBUTE + '"',
text: `data-long="${LONG_ATTRIBUTE}"`,
expectedAttributes: {
"data-long": LONG_ATTRIBUTE
},

Просмотреть файл

@ -42,19 +42,19 @@ function* testCollapsedLongAttribute(inspector, testActor) {
attr.focus();
EventUtils.sendKey("return", inspector.panelWin);
let input = inplaceEditor(attr).input;
is (input.value, 'data-long="' + LONG_ATTRIBUTE + '"');
is(input.value, `data-long="${LONG_ATTRIBUTE}"`);
EventUtils.sendKey("escape", inspector.panelWin);
setEditableFieldValue(attr, input.value + ' data-short="ABC"', inspector);
yield inspector.once("markupmutation");
let visibleAttrText = editor.attrElements.get("data-long").querySelector(".attr-value").textContent;
is (visibleAttrText, LONG_ATTRIBUTE_COLLAPSED)
is(visibleAttrText, LONG_ATTRIBUTE_COLLAPSED)
yield assertAttributes("#node24", {
id: "node24",
class: "",
'data-long': LONG_ATTRIBUTE,
"data-long": LONG_ATTRIBUTE,
"data-short": "ABC"
}, testActor);
}
@ -77,7 +77,7 @@ function* testModifyInlineStyleWithQuotes(inspector, testActor) {
let input = inplaceEditor(attr).input;
let value = input.value;
is (value,
is(value,
"style='background-image: url(\"moz-page-thumb://thumbnail?url=http%3A%2F%2Fwww.mozilla.org%2F\");'",
"Value contains actual double quotes"
);
@ -113,7 +113,7 @@ function* testEditingAttributeWithMixedQuotes(inspector, testActor) {
let input = inplaceEditor(attr).input;
let value = input.value;
is (value, "class=\"Double &quot; and single '\"", "Value contains &quot;");
is(value, "class=\"Double &quot; and single '\"", "Value contains &quot;");
value = value.replace(/Double/, "&quot;").replace(/single/, "'");
input.value = value;

Просмотреть файл

@ -9,7 +9,7 @@
const TEST_URL = "data:text/html;charset=utf-8,<div></div>";
add_task(function*() {
let {toolbox, inspector} = yield openInspectorForURL(TEST_URL);
let {inspector} = yield openInspectorForURL(TEST_URL);
yield inspector.markup.expandAll();
yield selectNode("div", inspector);
@ -20,7 +20,8 @@ add_task(function*() {
setEditableFieldValue(tagEditor, "<<<", inspector);
yield onCancelReselect;
ok(true, "The markup-view emitted the canceledreselectonremoved event");
is(inspector.selection.nodeFront, container.node, "The test DIV is still selected");
is(inspector.selection.nodeFront, container.node,
"The test DIV is still selected");
info("Updating the DIV tagname to a valid value this time");
let onReselect = inspector.markup.once("reselectedonremoved");
@ -29,5 +30,6 @@ add_task(function*() {
ok(true, "The markup-view emitted the reselectedonremoved event");
let spanFront = yield getNodeFront("span", inspector);
is(inspector.selection.nodeFront, spanFront, "The seelected node is now the SPAN");
is(inspector.selection.nodeFront, spanFront,
"The selected node is now the SPAN");
});

Просмотреть файл

@ -12,11 +12,13 @@ const TEST_URL = "data:text/html;charset=utf-8,<div></div>";
add_task(function*() {
let isEditTagNameCalled = false;
let {toolbox, inspector} = yield openInspectorForURL(TEST_URL);
let {inspector} = yield openInspectorForURL(TEST_URL);
// Overriding the editTagName walkerActor method here to check that it isn't
// called when blurring the tagname field.
inspector.walker.editTagName = function() { isEditTagNameCalled = true; }
inspector.walker.editTagName = function() {
isEditTagNameCalled = true;
};
yield selectNode("div", inspector);
let container = yield getContainerForSelector("div", inspector);
@ -33,4 +35,4 @@ add_task(function*() {
info("Updating the tagname to a different value");
setEditableFieldValue(tagEditor, "SPAN", inspector);
is(isEditTagNameCalled, true, "The editTagName method was called");
});
});

Просмотреть файл

@ -20,16 +20,20 @@ function* testAttributeEditing(inspector) {
info("Testing focus position after attribute editing");
info("Setting the first non-id attribute in edit mode");
yield activateFirstAttribute("#attr", inspector); // focuses id
collapseSelectionAndTab(inspector); // focuses the first attr after id
// focuses id
yield activateFirstAttribute("#attr", inspector);
// focuses the first attr after id
collapseSelectionAndTab(inspector);
let attrs = yield getAttributesFromEditor("#attr", inspector);
info("Editing this attribute, keeping the same name, and tabbing to the next");
info("Editing this attribute, keeping the same name, " +
"and tabbing to the next");
yield editAttributeAndTab(attrs[1] + '="99"', inspector);
checkFocusedAttribute(attrs[2], true);
info("Editing the new focused attribute, keeping the name, and tabbing to the previous");
info("Editing the new focused attribute, keeping the name, " +
"and tabbing to the previous");
yield editAttributeAndTab(attrs[2] + '="99"', inspector, true);
checkFocusedAttribute(attrs[1], true);
@ -45,8 +49,10 @@ function* testAttributeDeletion(inspector) {
info("Testing focus position after attribute deletion");
info("Setting the first non-id attribute in edit mode");
yield activateFirstAttribute("#delattr", inspector); // focuses id
collapseSelectionAndTab(inspector); // focuses the first attr after id
// focuses id
yield activateFirstAttribute("#delattr", inspector);
// focuses the first attr after id
collapseSelectionAndTab(inspector);
let attrs = yield getAttributesFromEditor("#delattr", inspector);
@ -59,12 +65,13 @@ function* testAttributeDeletion(inspector) {
// Check we're on the newattr element
let focusedAttr = Services.focus.focusedElement;
ok(focusedAttr.classList.contains("styleinspector-propertyeditor"), "in newattr");
ok(focusedAttr.classList.contains("styleinspector-propertyeditor"),
"in newattr");
is(focusedAttr.tagName, "input", "newattr is active");
}
function* editAttributeAndTab(newValue, inspector, goPrevious) {
var onEditMutation = inspector.markup.once("refocusedonedit");
let onEditMutation = inspector.markup.once("refocusedonedit");
inspector.markup.doc.activeElement.value = newValue;
if (goPrevious) {
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true },

Просмотреть файл

@ -6,7 +6,8 @@
// Tests that doesn't fit into any specific category.
const TEST_URL = "data:text/html;charset=utf8,<div a b id='order' c class></div>";
const TEST_URL = `data:text/html;charset=utf8,
<div a b id='order' c class></div>`;
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
@ -25,7 +26,6 @@ function* testOriginalAttributesOrder(inspector) {
function* testOrderAfterAttributeChange(inspector, testActor) {
info("Testing order of attributes after attribute is change by setAttribute");
let container = getContainerForSelector("#order", inspector);
yield testActor.setAttribute("#order", "a", "changed");
let attributes = yield getAttributesFromEditor("#order", inspector);

Просмотреть файл

@ -46,11 +46,13 @@ function* editContainer(inspector, {selector, newValue, oldValue, shortValue}) {
let field = container.elt.querySelector("pre");
if (shortValue) {
is (oldValue.indexOf(field.textContent.substring(0, field.textContent.length - 1)), 0,
"The shortened value starts with the full value " + field.textContent);
ok (oldValue.length > field.textContent.length, "The shortened value is short");
is(oldValue.indexOf(field.textContent.substring(0, field.textContent.length - 1)), 0,
"The shortened value starts with the full value " + field.textContent);
ok(oldValue.length > field.textContent.length,
"The shortened value is short");
} else {
is (field.textContent, oldValue, "The text node has the correct original value");
is(field.textContent, oldValue,
"The text node has the correct original value");
}
inspector.markup.markNodeAsSelected(container.node);
@ -60,7 +62,8 @@ function* editContainer(inspector, {selector, newValue, oldValue, shortValue}) {
yield inspector.markup.once("text-expand");
}
is (field.textContent, oldValue, "The text node has the correct original value after selecting");
is(field.textContent, oldValue,
"The text node has the correct original value after selecting");
setEditableFieldValue(field, newValue, inspector);
info("Listening to the markupmutation event");

Просмотреть файл

@ -32,9 +32,9 @@ add_task(function*() {
yield onUpdated;
info("Checking that child LI elements have been created");
for (let i = 0; i < content.document.querySelectorAll("li").length; i ++) {
for (let i = 0; i < content.document.querySelectorAll("li").length; i++) {
let liContainer = yield getContainerForSelector(
"li:nth-child(" + (i + 1) + ")", inspector);
`li:nth-child(${i + 1})`, inspector);
ok(liContainer, "A container for the child LI element was created");
}
ok(container.expanded, "Parent UL container is expanded");
@ -46,9 +46,9 @@ add_task(function*() {
inspector.markup.doc.defaultView);
info("Checking that child LI elements have been hidden");
for (let i = 0; i < content.document.querySelectorAll("li").length; i ++) {
for (let i = 0; i < content.document.querySelectorAll("li").length; i++) {
let liContainer = yield getContainerForSelector(
"li:nth-child(" + (i + 1) + ")", inspector);
`li:nth-child(${i + 1})`, inspector);
is(liContainer.elt.getClientRects().length, 0,
"The container for the child LI element was hidden");
}

Просмотреть файл

@ -23,7 +23,7 @@ add_task(function*() {
yield onUpdated;
info("Checking that child LI elements have been created");
for (let i = 0; i < content.document.querySelectorAll("li").length; i ++) {
for (let i = 0; i < content.document.querySelectorAll("li").length; i++) {
let liContainer = yield getContainerForSelector(
"li:nth-child(" + (i + 1) + ")", inspector);
ok(liContainer, "A container for the child LI element was created");
@ -37,7 +37,7 @@ add_task(function*() {
inspector.markup.doc.defaultView);
info("Checking that child LI elements have been hidden");
for (let i = 0; i < content.document.querySelectorAll("li").length; i ++) {
for (let i = 0; i < content.document.querySelectorAll("li").length; i++) {
let liContainer = yield getContainerForSelector(
"li:nth-child(" + (i + 1) + ")", inspector);
is(liContainer.elt.getClientRects().length, 0,

Просмотреть файл

@ -1,6 +1,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from ../../test/head.js */
"use strict";
// Import the inspector's head.js first (which itself imports shared-head.js).
@ -10,7 +12,7 @@ Services.scriptloader.loadSubScript(
var {getInplaceEditorForSpan: inplaceEditor} = require("devtools/client/shared/inplace-editor");
var clipboard = require("sdk/clipboard");
var {setTimeout, clearTimeout} = require("sdk/timers");
var {ActorRegistryFront} = require("devtools/server/actors/actor-registry");
// If a test times out we want to see the complete log and not just the last few
// lines.
@ -32,8 +34,8 @@ registerCleanupFunction(() => {
/**
* Some tests may need to import one or more of the test helper scripts.
* A test helper script is simply a js file that contains common test code that
* is either not common-enough to be in head.js, or that is located in a separate
* directory.
* is either not common-enough to be in head.js, or that is located in a
* separate directory.
* The script will be loaded synchronously and in the test's scope.
* @param {String} filePath The file path, relative to the current directory.
* Examples:
@ -178,7 +180,9 @@ var clickContainer = Task.async(function*(selector, inspector) {
let nodeFront = yield getNodeFront(selector, inspector);
let container = getContainerForNodeFront(nodeFront, inspector);
let updated = container.selected ? promise.resolve() : inspector.once("inspector-updated");
let updated = container.selected
? promise.resolve()
: inspector.once("inspector-updated");
EventUtils.synthesizeMouseAtCenter(container.tagLine, {type: "mousedown"},
inspector.markup.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(container.tagLine, {type: "mouseup"},
@ -186,16 +190,6 @@ var clickContainer = Task.async(function*(selector, inspector) {
return updated;
});
/**
* Checks if the highlighter is visible currently
* @return {Boolean}
*/
function isHighlighterVisible() {
let highlighter = gBrowser.selectedBrowser.parentNode
.querySelector(".highlighter-container .box-model-root");
return highlighter && !highlighter.hasAttribute("hidden");
}
/**
* Focus a given editable element, enter edit mode, set value, and commit
* @param {DOMNode} field The element that gets editable after receiving focus
@ -224,7 +218,7 @@ function setEditableFieldValue(field, value, inspector) {
* @return a promise that resolves when the node has mutated
*/
var addNewAttributes = Task.async(function*(selector, text, inspector) {
info("Entering text '" + text + "' in node '" + selector + "''s new attribute field");
info(`Entering text "${text}" in new attribute field for node ${selector}`);
let container = yield getContainerForSelector(selector, inspector);
ok(container, "The container for '" + selector + "' was found");
@ -252,7 +246,7 @@ var assertAttributes = Task.async(function*(selector, expected, testActor) {
is(actual.length, Object.keys(expected).length,
"The node " + selector + " has the expected number of attributes.");
for (let attr in expected) {
let foundAttr = actual.find(({name, value}) => name === attr);
let foundAttr = actual.find(({name}) => name === attr);
let foundValue = foundAttr ? foundAttr.value : undefined;
ok(foundAttr, "The node " + selector + " has the attribute " + attr);
is(foundValue, expected[attr],
@ -344,10 +338,12 @@ function wait(ms) {
* @return A promise that resolves with a boolean indicating whether
* the menu items are disabled once the menu has been checked.
*/
var isEditingMenuDisabled = Task.async(function*(nodeFront, inspector, assert=true) {
let deleteMenuItem = inspector.panelDoc.getElementById("node-menu-delete");
let editHTMLMenuItem = inspector.panelDoc.getElementById("node-menu-edithtml");
let pasteHTMLMenuItem = inspector.panelDoc.getElementById("node-menu-pasteouterhtml");
var isEditingMenuDisabled = Task.async(
function*(nodeFront, inspector, assert = true) {
let doc = inspector.panelDoc;
let deleteMenuItem = doc.getElementById("node-menu-delete");
let editHTMLMenuItem = doc.getElementById("node-menu-edithtml");
let pasteHTMLMenuItem = doc.getElementById("node-menu-pasteouterhtml");
// To ensure clipboard contains something to paste.
clipboard.set("<p>test</p>", "html");
@ -366,7 +362,9 @@ var isEditingMenuDisabled = Task.async(function*(nodeFront, inspector, assert=tr
ok(isPasteHTMLMenuDisabled, "Paste HTML menu item is disabled");
}
return isDeleteMenuDisabled && isEditHTMLMenuDisabled && isPasteHTMLMenuDisabled;
return isDeleteMenuDisabled &&
isEditHTMLMenuDisabled &&
isPasteHTMLMenuDisabled;
});
/**
@ -378,10 +376,12 @@ var isEditingMenuDisabled = Task.async(function*(nodeFront, inspector, assert=tr
* @return A promise that resolves with a boolean indicating whether
* the menu items are enabled once the menu has been checked.
*/
var isEditingMenuEnabled = Task.async(function*(nodeFront, inspector, assert=true) {
let deleteMenuItem = inspector.panelDoc.getElementById("node-menu-delete");
let editHTMLMenuItem = inspector.panelDoc.getElementById("node-menu-edithtml");
let pasteHTMLMenuItem = inspector.panelDoc.getElementById("node-menu-pasteouterhtml");
var isEditingMenuEnabled = Task.async(
function*(nodeFront, inspector, assert = true) {
let doc = inspector.panelDoc;
let deleteMenuItem = doc.getElementById("node-menu-delete");
let editHTMLMenuItem = doc.getElementById("node-menu-edithtml");
let pasteHTMLMenuItem = doc.getElementById("node-menu-pasteouterhtml");
// To ensure clipboard contains something to paste.
clipboard.set("<p>test</p>", "html");
@ -400,7 +400,9 @@ var isEditingMenuEnabled = Task.async(function*(nodeFront, inspector, assert=tru
ok(!isPasteHTMLMenuDisabled, "Paste HTML menu item is enabled");
}
return !isDeleteMenuDisabled && !isEditHTMLMenuDisabled && !isPasteHTMLMenuDisabled;
return !isDeleteMenuDisabled &&
!isEditHTMLMenuDisabled &&
!isPasteHTMLMenuDisabled;
});
/**
@ -437,8 +439,10 @@ function promiseNextTick() {
* field.
*/
function collapseSelectionAndTab(inspector) {
EventUtils.sendKey("tab", inspector.panelWin); // collapse selection and move caret to end
EventUtils.sendKey("tab", inspector.panelWin); // next element
// collapse selection and move caret to end
EventUtils.sendKey("tab", inspector.panelWin);
// next element
EventUtils.sendKey("tab", inspector.panelWin);
}
/**
@ -446,10 +450,12 @@ function collapseSelectionAndTab(inspector) {
* previous field.
*/
function collapseSelectionAndShiftTab(inspector) {
// collapse selection and move caret to end
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true },
inspector.panelWin); // collapse selection and move caret to end
inspector.panelWin);
// previous element
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true },
inspector.panelWin); // previous element
inspector.panelWin);
}
/**
@ -461,10 +467,12 @@ function collapseSelectionAndShiftTab(inspector) {
function checkFocusedAttribute(attrName, editMode) {
let focusedAttr = Services.focus.focusedElement;
is(focusedAttr ? focusedAttr.parentNode.dataset.attr : undefined,
attrName, attrName + " attribute editor is currently focused.");
attrName, attrName + " attribute editor is currently focused.");
is(focusedAttr ? focusedAttr.tagName : undefined,
editMode ? "input": "span",
editMode ? attrName + " is in edit mode" : attrName + " is not in edit mode");
editMode ? "input" : "span",
editMode
? attrName + " is in edit mode"
: attrName + " is not in edit mode");
}
/**
@ -484,8 +492,8 @@ var getAttributesFromEditor = Task.async(function*(selector, inspector) {
});
// The expand all operation of the markup-view calls itself recursively and
// there's not one event we can wait for to know when it's done
// so use this helper function to wait until all recursive children updates are done.
// there's not one event we can wait for to know when it's done so use this
// helper function to wait until all recursive children updates are done.
function* waitForMultipleChildrenUpdates(inspector) {
// As long as child updates are queued up while we wait for an update already
// wait again
@ -531,12 +539,12 @@ function createTestHTTPServer() {
* A helper that simulates a contextmenu event on the given chrome DOM element.
*/
function contextMenuClick(element) {
let evt = element.ownerDocument.createEvent('MouseEvents');
let button = 2; // right click
let evt = element.ownerDocument.createEvent("MouseEvents");
let buttonRight = 2;
evt.initMouseEvent('contextmenu', true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, button, null);
evt.initMouseEvent("contextmenu", true, true,
element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false,
false, buttonRight, null);
element.dispatchEvent(evt);
}
@ -573,12 +581,10 @@ function registerTabActor(client, options) {
// Register the custom actor on the backend.
let registry = ActorRegistryFront(client, response);
return registry.registerActor(moduleUrl, config).then(registrar => {
return client.getTab().then(response => {
return {
registrar: registrar,
form: response.tab
};
});
return client.getTab().then(tabResponse => ({
registrar: registrar,
form: tabResponse.tab
}));
});
});
}

Просмотреть файл

@ -1,6 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from head.js */
"use strict";
/**
* Run a series of add-attributes tests.
@ -39,10 +42,10 @@ function runAddAttributesTests(tests, nodeOrSelector, inspector, testActor) {
* - text {String} the string to be inserted into the new attribute field
* - expectedAttributes {Object} a key/value pair object that will be
* used to check the attributes on the test element
* - validate {Function} optional extra function that will be called after
* the attributes have been added and which should be used to assert some
* more things this test runner might not be checking. The function will
* be called with the following arguments:
* - validate {Function} optional extra function that will be called
* after the attributes have been added and which should be used to
* assert some more things this test runner might not be checking. The
* function will be called with the following arguments:
* - {DOMNode} The element being tested
* - {MarkupContainer} The corresponding container in the markup-view
* - {InspectorPanel} The instance of the InspectorPanel opened
@ -81,9 +84,9 @@ function* runAddAttributesTest(test, selector, inspector, testActor) {
/**
* Run a series of edit-attributes tests.
* This function will iterate over the provided tests array and run each test.
* Each test's goal is to locate a given element on the current test page, assert
* its current attributes, then provide the name of one of them and a value to
* be set into it, and then check if the new attributes are correct.
* Each test's goal is to locate a given element on the current test page,
* assert its current attributes, then provide the name of one of them and a
* value to be set into it, and then check if the new attributes are correct.
* After each test has run, the markup-view's undo and redo commands will be
* called and the test runner will assert again that the attributes are correct.
* @param {Array} tests See runEditAttributesTest for the structure
@ -139,7 +142,8 @@ function* runEditAttributesTest(test, inspector, testActor) {
info("Listening for the markupmutation event");
let nodeMutated = inspector.once("markupmutation");
let attr = container.editor.attrElements.get(test.name).querySelector(".editable");
let attr = container.editor.attrElements.get(test.name)
.querySelector(".editable");
setEditableFieldValue(attr, test.value, inspector);
yield nodeMutated;
@ -150,7 +154,8 @@ function* runEditAttributesTest(test, inspector, testActor) {
yield undoChange(inspector);
yield assertAttributes(test.node, test.originalAttributes, testActor);
info("Redo the change and assert that the attributes have been changed again");
info("Redo the change and assert that the attributes have been changed " +
"again");
yield redoChange(inspector);
yield assertAttributes(test.node, test.expectedAttributes, testActor);
}

Просмотреть файл

@ -1,17 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from head.js */
"use strict";
/**
* Generator function that runs checkEventsForNode() for each object in the
* TEST_DATA array.
*/
function* runEventPopupTests() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
function* runEventPopupTests(url, tests) {
let {inspector, testActor} = yield openInspectorForURL(url);
yield inspector.markup.expandAll();
for (let test of TEST_DATA) {
for (let test of tests) {
yield checkEventsForNode(test, inspector, testActor);
}
@ -61,7 +64,8 @@ function* checkEventsForNode(test, inspector, testActor) {
// Click button to show tooltip
info("Clicking evHolder");
EventUtils.synthesizeMouseAtCenter(evHolder, {}, inspector.markup.doc.defaultView);
EventUtils.synthesizeMouseAtCenter(evHolder, {},
inspector.markup.doc.defaultView);
yield tooltip.once("shown");
info("tooltip shown");

Просмотреть файл

@ -1,6 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from head.js */
"use strict";
/**
* Run a series of edit-outer-html tests.
@ -42,7 +45,6 @@ function runEditOuterHTMLTests(tests, inspector, testActor) {
function* runEditOuterHTMLTest(test, inspector, testActor) {
info("Running an edit outerHTML test on '" + test.selector + "'");
yield selectNode(test.selector, inspector);
let oldNodeFront = inspector.selection.nodeFront;
let onUpdated = inspector.once("inspector-updated");
@ -55,13 +57,15 @@ function* runEditOuterHTMLTest(test, inspector, testActor) {
// Typically selectedNode will === pageNode, but if a new element has been
// injected in front of it, this will not be the case. If this happens.
let selectedNodeFront = inspector.selection.nodeFront;
let pageNodeFront = yield inspector.walker.querySelector(inspector.walker.rootNode, test.selector);
let pageNodeFront = yield inspector.walker.querySelector(
inspector.walker.rootNode, test.selector);
let pageNode = getNode(test.selector);
if (test.validate) {
yield test.validate(pageNode, pageNodeFront, selectedNodeFront, inspector);
} else {
is(pageNodeFront, selectedNodeFront, "Original node (grabbed by selector) is selected");
is(pageNodeFront, selectedNodeFront,
"Original node (grabbed by selector) is selected");
let {outerHTML} = yield getNodeInfo(test.selector, testActor);
is(outerHTML, test.newHTML, "Outer HTML has been updated");
}
@ -72,6 +76,7 @@ function* runEditOuterHTMLTest(test, inspector, testActor) {
let closeTagLine = inspector.markup.getContainer(pageNodeFront).closeTagLine;
if (closeTagLine) {
is(closeTagLine.querySelectorAll(".theme-fg-contrast").length, 0, "No contrast class");
is(closeTagLine.querySelectorAll(".theme-fg-contrast").length, 0,
"No contrast class");
}
}