This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MozReview-Commit-ID: 62e9XDudUlc
- Loading branch information
Showing
3,424 changed files
with
41,719 additions
and
54,109 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
devtools/client/inspector/rules/test/browser_rules_class_panel_add.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* 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"; | ||
|
||
// Test that classes can be added in the class panel | ||
|
||
// This array contains the list of test cases. Each test case contains these properties: | ||
// - {String} textEntered The text to be entered in the field | ||
// - {Boolean} expectNoMutation Set to true if we shouldn't wait for a DOM mutation | ||
// - {Array} expectedClasses The expected list of classes to be applied to the DOM and to | ||
// be found in the class panel | ||
const TEST_ARRAY = [{ | ||
textEntered: "", | ||
expectNoMutation: true, | ||
expectedClasses: [] | ||
}, { | ||
textEntered: "class", | ||
expectedClasses: ["class"] | ||
}, { | ||
textEntered: "class", | ||
expectNoMutation: true, | ||
expectedClasses: ["class"] | ||
}, { | ||
textEntered: "a a a a a a a a a a", | ||
expectedClasses: ["class", "a"] | ||
}, { | ||
textEntered: "class2 class3", | ||
expectedClasses: ["class", "a", "class2", "class3"] | ||
}, { | ||
textEntered: " ", | ||
expectNoMutation: true, | ||
expectedClasses: ["class", "a", "class2", "class3"] | ||
}, { | ||
textEntered: " class4", | ||
expectedClasses: ["class", "a", "class2", "class3", "class4"] | ||
}, { | ||
textEntered: " \t class5 \t \t\t ", | ||
expectedClasses: ["class", "a", "class2", "class3", "class4", "class5"] | ||
}]; | ||
|
||
add_task(function* () { | ||
yield addTab("data:text/html;charset=utf-8,"); | ||
let {testActor, inspector, view} = yield openRuleView(); | ||
|
||
info("Open the class panel"); | ||
view.showClassPanel(); | ||
|
||
const textField = inspector.panelDoc.querySelector("#ruleview-class-panel .add-class"); | ||
ok(textField, "The input field exists in the class panel"); | ||
|
||
textField.focus(); | ||
|
||
let onMutation; | ||
for (let {textEntered, expectNoMutation, expectedClasses} of TEST_ARRAY) { | ||
if (!expectNoMutation) { | ||
onMutation = inspector.once("markupmutation"); | ||
} | ||
|
||
info(`Enter the test string in the field: ${textEntered}`); | ||
for (let key of textEntered.split("")) { | ||
EventUtils.synthesizeKey(key, {}, view.styleWindow); | ||
} | ||
|
||
info("Submit the change and wait for the textfield to become empty"); | ||
let onEmpty = waitForFieldToBeEmpty(textField); | ||
EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow); | ||
|
||
if (!expectNoMutation) { | ||
info("Wait for the DOM to change"); | ||
yield onMutation; | ||
} | ||
|
||
yield onEmpty; | ||
|
||
info("Check the state of the DOM node"); | ||
let className = yield testActor.getAttribute("body", "class"); | ||
let expectedClassName = expectedClasses.length ? expectedClasses.join(" ") : null; | ||
is(className, expectedClassName, "The DOM node has the right className"); | ||
|
||
info("Check the content of the class panel"); | ||
checkClassPanelContent(view, expectedClasses.map(name => { | ||
return {name, state: true}; | ||
})); | ||
} | ||
}); | ||
|
||
function waitForFieldToBeEmpty(textField) { | ||
return waitForSuccess(() => !textField.value); | ||
} |
Oops, something went wrong.