зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1181839 - Include inspector/test/head.js (which imports shared-head.js) in animationinspector's tests and removes code duplication. r=pbro
MozReview-Commit-ID: GrsOewqAggD --HG-- extra : rebase_source : 069d715fa2fc7a71a6615bd3a657a6211564584c
This commit is contained in:
Родитель
f7a0ff2a51
Коммит
9c8b86de81
|
@ -22,7 +22,7 @@ const EXPECTED_PROPERTIES = [
|
|||
].sort();
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_keyframes.html");
|
||||
yield addTab(URL_ROOT + "doc_keyframes.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
let propertiesList = timeline.rootWrapperEl
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// them, and that this emits the right events and adds the right classes.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// the last known version since new animations were added).
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel, controller} = yield openAnimationInspector();
|
||||
|
||||
ok(controller.documentCurrentTime, "The documentCurrentTime getter exists");
|
||||
|
|
|
@ -11,14 +11,14 @@ const STRINGS_URI = "chrome://devtools/locale/animationinspector.properties";
|
|||
const L10N = new ViewHelpers.L10N(STRINGS_URI);
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel, window} = yield openAnimationInspector();
|
||||
let {document} = window;
|
||||
|
||||
info("Select node .still and check that the panel is empty");
|
||||
let stillNode = yield getNodeFront(".still", inspector);
|
||||
let onUpdated = panel.once(panel.UI_UPDATED_EVENT);
|
||||
yield selectNode(stillNode, inspector);
|
||||
yield selectNodeAndWaitForAnimations(stillNode, inspector);
|
||||
yield onUpdated;
|
||||
|
||||
is(panel.animationsTimelineComponent.animations.length, 0,
|
||||
|
@ -32,7 +32,7 @@ add_task(function*() {
|
|||
info("Select the comment text node and check that the panel is empty");
|
||||
let commentNode = yield inspector.walker.previousSibling(stillNode);
|
||||
onUpdated = panel.once(panel.UI_UPDATED_EVENT);
|
||||
yield selectNode(commentNode, inspector);
|
||||
yield selectNodeAndWaitForAnimations(commentNode, inspector);
|
||||
yield onUpdated;
|
||||
|
||||
is(panel.animationsTimelineComponent.animations.length, 0,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// sets the current time in the timeline.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_keyframes.html");
|
||||
yield addTab(URL_ROOT + "doc_keyframes.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
let {scrubberEl} = timeline;
|
||||
|
|
|
@ -22,7 +22,7 @@ const EXPECTED_PROPERTIES = [
|
|||
];
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_keyframes.html");
|
||||
yield addTab(URL_ROOT + "doc_keyframes.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// different nodes).
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_negative_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_negative_animation.html");
|
||||
let {controller, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Wait until all animations have been added " +
|
||||
|
|
|
@ -11,7 +11,7 @@ requestLongerTimeout(2);
|
|||
// inspector-updated event is emitted *after* the animation panel is ready.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel, controller} = yield openAnimationInspector();
|
||||
|
||||
info("Listen for the players-updated, ui-updated and " +
|
||||
|
@ -29,7 +29,7 @@ add_task(function*() {
|
|||
|
||||
info("Selecting an animated node");
|
||||
let node = yield getNodeFront(".animated", inspector);
|
||||
yield selectNode(node, inspector);
|
||||
yield selectNodeAndWaitForAnimations(node, inspector);
|
||||
|
||||
info("Check that all events were received");
|
||||
// Only assert that the inspector-updated event is last, the order of the
|
||||
|
|
|
@ -10,26 +10,26 @@ requestLongerTimeout(2);
|
|||
// AnimationController.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {controller, inspector} = yield openAnimationInspector();
|
||||
|
||||
info("Selecting an animated node");
|
||||
// selectNode waits for the inspector-updated event before resolving, which
|
||||
// means the controller.PLAYERS_UPDATED_EVENT event has been emitted before
|
||||
// and players are ready.
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
is(controller.animationPlayers.length, 1,
|
||||
"One AnimationPlayerFront has been created");
|
||||
|
||||
info("Selecting a node with mutliple animations");
|
||||
yield selectNode(".multi", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".multi", inspector);
|
||||
|
||||
is(controller.animationPlayers.length, 2,
|
||||
"2 AnimationPlayerFronts have been created");
|
||||
|
||||
info("Selecting a node with no animations");
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
is(controller.animationPlayers.length, 0,
|
||||
"There are no more AnimationPlayerFront objects");
|
||||
|
|
|
@ -16,7 +16,7 @@ add_task(function*() {
|
|||
]}, resolve);
|
||||
});
|
||||
|
||||
yield addTab(TEST_URL_ROOT + "doc_multiple_animation_types.html");
|
||||
yield addTab(URL_ROOT + "doc_multiple_animation_types.html");
|
||||
|
||||
let {panel} = yield openAnimationInspector();
|
||||
is(panel.animationsTimelineComponent.animations.length, 3,
|
||||
|
|
|
@ -9,11 +9,11 @@ requestLongerTimeout(2);
|
|||
// Test that player widgets display information about target nodes
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Select the simple animated node");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
let targetNodeComponent = panel.animationsTimelineComponent.targetNodes[0];
|
||||
let {previewer} = targetNodeComponent;
|
||||
|
|
|
@ -9,11 +9,11 @@ requestLongerTimeout(2);
|
|||
// Test that the panel content refreshes when new animations are added.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Select a non animated node");
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
assertAnimationsDisplayed(panel, 0);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ requestLongerTimeout(2);
|
|||
// Test that the panel content refreshes when animations are removed.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
yield testRefreshOnRemove(inspector, panel);
|
||||
|
@ -17,7 +17,7 @@ add_task(function*() {
|
|||
|
||||
function* testRefreshOnRemove(inspector, panel) {
|
||||
info("Select a animated node");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
assertAnimationsDisplayed(panel, 1);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ requestLongerTimeout(2);
|
|||
// Test that the panel only refreshes when it is visible in the sidebar.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
yield testRefresh(inspector, panel);
|
||||
|
@ -17,13 +17,13 @@ add_task(function*() {
|
|||
|
||||
function* testRefresh(inspector, panel) {
|
||||
info("Select a non animated node");
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
info("Switch to the rule-view panel");
|
||||
inspector.sidebar.select("ruleview");
|
||||
|
||||
info("Select the animated node now");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
assertAnimationsDisplayed(panel, 0,
|
||||
"The panel doesn't show the animation data while inactive");
|
||||
|
@ -39,7 +39,7 @@ function* testRefresh(inspector, panel) {
|
|||
inspector.sidebar.select("ruleview");
|
||||
|
||||
info("Select the non animated node again");
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
assertAnimationsDisplayed(panel, 1,
|
||||
"The panel still shows the previous animation data since it is inactive");
|
||||
|
|
|
@ -13,12 +13,12 @@ const STRINGS_URI = "chrome://devtools/locale/animationinspector.properties";
|
|||
const L10N = new ViewHelpers.L10N(STRINGS_URI);
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
||||
info("Select a test node we know has an animation running on the compositor");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
let animationEl = timeline.animationsEl.querySelector(".animation");
|
||||
ok(animationEl.classList.contains("fast-track"),
|
||||
|
@ -27,7 +27,7 @@ add_task(function*() {
|
|||
"The animation element has the right tooltip content");
|
||||
|
||||
info("Select a node we know doesn't have an animation on the compositor");
|
||||
yield selectNode(".no-compositor", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".no-compositor", inspector);
|
||||
|
||||
animationEl = timeline.animationsEl.querySelector(".animation");
|
||||
ok(!animationEl.classList.contains("fast-track"),
|
||||
|
|
|
@ -10,12 +10,12 @@ requestLongerTimeout(2);
|
|||
// are created in the panel.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel, controller} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
||||
info("Selecting the test animated node again");
|
||||
yield selectNode(".multi", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".multi", inspector);
|
||||
|
||||
is(controller.animationPlayers.length,
|
||||
timeline.animationsEl.querySelectorAll(".animation").length,
|
||||
|
|
|
@ -10,12 +10,12 @@ requestLongerTimeout(2);
|
|||
// selected.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Select node .animated and check that the panel is not empty");
|
||||
let node = yield getNodeFront(".animated", inspector);
|
||||
yield selectNode(node, inspector);
|
||||
yield selectNodeAndWaitForAnimations(node, inspector);
|
||||
|
||||
assertAnimationsDisplayed(panel, 1);
|
||||
});
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
// browser_animation_toggle_button_toggles_animation.js
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel, inspector, window, controller} = yield openAnimationInspector();
|
||||
let {toggleAllButtonEl} = panel;
|
||||
|
||||
// select a node without animations
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
// ensure the focus is on the animation panel
|
||||
window.focus();
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// is selected, animations will be displayed in the timeline, so the timeline
|
||||
// play/resume button will be displayed
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel, window} = yield openAnimationInspector();
|
||||
let {playTimelineButtonEl} = panel;
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ requestLongerTimeout(2);
|
|||
// be used to highlight elements in the DOM and select them in the inspector.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {toolbox, inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Select the simple animated node");
|
||||
let onPanelUpdated = panel.once(panel.UI_UPDATED_EVENT);
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
yield onPanelUpdated;
|
||||
|
||||
let targets = yield waitForAllAnimationTargets(panel);
|
||||
|
@ -50,7 +50,7 @@ add_task(function*() {
|
|||
|
||||
info("Select the body node in order to have the list of all animations");
|
||||
onPanelUpdated = panel.once(panel.UI_UPDATED_EVENT);
|
||||
yield selectNode("body", inspector);
|
||||
yield selectNodeAndWaitForAnimations("body", inspector);
|
||||
yield onPanelUpdated;
|
||||
|
||||
targets = yield waitForAllAnimationTargets(panel);
|
||||
|
|
|
@ -10,7 +10,7 @@ requestLongerTimeout(2);
|
|||
// be used to highlight elements in the DOM and select them in the inspector.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
let targets = panel.animationsTimelineComponent.targetNodes;
|
||||
|
|
|
@ -11,7 +11,7 @@ requestLongerTimeout(2);
|
|||
// rewound, and stops when animations are paused.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {panel} = yield openAnimationInspector();
|
||||
let label = panel.timelineCurrentTimeEl;
|
||||
|
|
|
@ -15,7 +15,7 @@ const {findOptimalTimeInterval, TimeScale} = require("devtools/client/animationi
|
|||
const TIME_GRADUATION_MIN_SPACING = 40;
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
|
|
@ -17,7 +17,7 @@ requestLongerTimeout(2);
|
|||
// the timeline does the right thing.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {panel, inspector} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
@ -45,7 +45,7 @@ add_task(function*() {
|
|||
// at the end of the timeline, and the button should remain in play mode.
|
||||
info("Select an infinite animation, reload the page and wait for the " +
|
||||
"animation to complete");
|
||||
yield selectNode(".multi", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".multi", inspector);
|
||||
yield reloadTab(inspector);
|
||||
yield waitForOutOfBoundScrubber(timeline);
|
||||
|
||||
|
@ -64,7 +64,7 @@ add_task(function*() {
|
|||
// timeline, it should go back to paused mode.
|
||||
info("Select a finite animation, reload the page and wait for the " +
|
||||
"animation to complete");
|
||||
yield selectNode(".negative-delay", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".negative-delay", inspector);
|
||||
|
||||
let onScrubberStopped = waitForScrubberStopped(timeline);
|
||||
yield reloadTab(inspector);
|
||||
|
|
|
@ -13,7 +13,7 @@ requestLongerTimeout(2);
|
|||
// have mixed rates.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {panel, controller, inspector, toolbox} = yield openAnimationInspector();
|
||||
|
||||
|
@ -34,13 +34,13 @@ add_task(function*() {
|
|||
checkAllAnimationsRatesChanged(controller, select, .5);
|
||||
|
||||
info("Select just one animated node and change its rate only");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
yield changeTimelinePlaybackRate(panel, 2);
|
||||
checkAllAnimationsRatesChanged(controller, select, 2);
|
||||
|
||||
info("Select the <body> again, it should now have mixed-rates animations");
|
||||
yield selectNode("body", inspector);
|
||||
yield selectNodeAndWaitForAnimations("body", inspector);
|
||||
|
||||
is(select.value, "", "The selected rate is empty");
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ requestLongerTimeout(2);
|
|||
// start.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {panel, controller} = yield openAnimationInspector();
|
||||
let players = controller.animationPlayers;
|
||||
|
|
|
@ -9,7 +9,7 @@ requestLongerTimeout(2);
|
|||
// Check that the timeline does have a scrubber element.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
|
|
@ -13,7 +13,7 @@ requestLongerTimeout(2);
|
|||
// Finally, also check that the scrubber can be moved using the scrubber handle.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
|
||||
let {panel} = yield openAnimationInspector();
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
|
|
@ -12,7 +12,7 @@ requestLongerTimeout(2);
|
|||
// and measures its position again.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
|
|
@ -12,20 +12,20 @@ requestLongerTimeout(2);
|
|||
// positive delays.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Selecting a delayed animated node");
|
||||
yield selectNode(".delayed", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".delayed", inspector);
|
||||
let timelineEl = panel.animationsTimelineComponent.rootWrapperEl;
|
||||
checkDelayAndName(timelineEl, true);
|
||||
|
||||
info("Selecting a no-delay animated node");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
checkDelayAndName(timelineEl, false);
|
||||
|
||||
info("Selecting a negative-delay animated node");
|
||||
yield selectNode(".negative-delay", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".negative-delay", inspector);
|
||||
checkDelayAndName(timelineEl, true);
|
||||
});
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ requestLongerTimeout(2);
|
|||
// iterations in an animation.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Selecting the test node");
|
||||
yield selectNode(".delayed", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".delayed", inspector);
|
||||
|
||||
info("Getting the animation element from the panel");
|
||||
let timelineEl = panel.animationsTimelineComponent.rootWrapperEl;
|
||||
|
@ -32,7 +32,7 @@ add_task(function*() {
|
|||
"The iteration element doesn't have the infinite class");
|
||||
|
||||
info("Selecting another test node with an infinite animation");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
info("Getting the animation element from the panel again");
|
||||
animation = timelineEl.querySelector(".time-block");
|
||||
|
|
|
@ -10,7 +10,7 @@ requestLongerTimeout(2);
|
|||
// counts in tooltips.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel, controller} = yield openAnimationInspector();
|
||||
|
||||
info("Getting the animation element from the panel");
|
||||
|
|
|
@ -18,7 +18,7 @@ add_task(function*() {
|
|||
]}, resolve);
|
||||
});
|
||||
|
||||
yield addTab(TEST_URL_ROOT + "doc_modify_playbackRate.html");
|
||||
yield addTab(URL_ROOT + "doc_modify_playbackRate.html");
|
||||
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ requestLongerTimeout(2);
|
|||
// Check that the timeline contains the right elements.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
let timeline = panel.animationsTimelineComponent;
|
||||
|
|
|
@ -9,11 +9,11 @@ requestLongerTimeout(2);
|
|||
// Test that a page navigation resets the state of the global toggle button.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, panel} = yield openAnimationInspector();
|
||||
|
||||
info("Select the non-animated test node");
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
ok(!panel.toggleAllButtonEl.classList.contains("paused"),
|
||||
"The toggle button is in its running state by default");
|
||||
|
|
|
@ -12,7 +12,7 @@ requestLongerTimeout(2);
|
|||
// actor test in /devtools/server/tests/browser/ that does this.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel} = yield openAnimationInspector();
|
||||
|
||||
info("Click the toggle button");
|
||||
|
|
|
@ -12,7 +12,7 @@ requestLongerTimeout(2);
|
|||
// are animations to be displayed.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {inspector, window} = yield openAnimationInspector();
|
||||
let doc = window.document;
|
||||
let toolbar = doc.querySelector("#global-toolbar");
|
||||
|
@ -27,7 +27,7 @@ add_task(function*() {
|
|||
"The timeline toolbar is visible when there are animations");
|
||||
|
||||
info("Select a node that has no animations");
|
||||
yield selectNode(".still", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".still", inspector);
|
||||
|
||||
ok(isNodeVisible(toolbar),
|
||||
"The toolbar is shown when there are no animations");
|
||||
|
|
|
@ -10,11 +10,11 @@ requestLongerTimeout(2);
|
|||
// content, then the widget reflects the changes.
|
||||
|
||||
add_task(function*() {
|
||||
yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
|
||||
yield addTab(URL_ROOT + "doc_simple_animation.html");
|
||||
let {panel, controller, inspector} = yield openAnimationInspector();
|
||||
|
||||
info("Select the test node");
|
||||
yield selectNode(".animated", inspector);
|
||||
yield selectNodeAndWaitForAnimations(".animated", inspector);
|
||||
|
||||
let animation = controller.animationPlayers[0];
|
||||
yield setStyle(animation, panel, "animationDuration", "5.5s");
|
||||
|
|
|
@ -5,21 +5,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var Cu = Components.utils;
|
||||
const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const {gDevTools} = require("devtools/client/framework/devtools");
|
||||
const promise = require("promise");
|
||||
const {TargetFactory} = require("devtools/client/framework/target");
|
||||
const {console} = Cu.import("resource://gre/modules/Console.jsm", {});
|
||||
/* import-globals-from ../../inspector/test/head.js */
|
||||
// Import the inspector's head.js first (which itself imports shared-head.js).
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/devtools/client/inspector/test/head.js",
|
||||
this);
|
||||
|
||||
const {ViewHelpers} = Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm", {});
|
||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
|
||||
// All tests are asynchronous
|
||||
waitForExplicitFinish();
|
||||
|
||||
const TEST_URL_ROOT = "http://example.com/browser/devtools/client/animationinspector/test/";
|
||||
const ROOT_TEST_DIR = getRootDirectory(gTestPath);
|
||||
const FRAME_SCRIPT_URL = ROOT_TEST_DIR + "doc_frame_script.js";
|
||||
const FRAME_SCRIPT_URL = CHROME_URL_ROOT + "doc_frame_script.js";
|
||||
const COMMON_FRAME_SCRIPT_URL = "chrome://devtools/content/shared/frame-script-utils.js";
|
||||
const TAB_NAME = "animationinspector";
|
||||
|
||||
|
@ -32,20 +25,9 @@ registerCleanupFunction(function*() {
|
|||
}
|
||||
});
|
||||
|
||||
// Uncomment this pref to dump all devtools emitted events to the console.
|
||||
// Services.prefs.setBoolPref("devtools.dump.emit", true);
|
||||
|
||||
// Uncomment this pref to dump all devtools protocol traffic
|
||||
// Services.prefs.setBoolPref("devtools.debugger.log", true);
|
||||
|
||||
// Set the testing flag on DevToolsUtils and reset it when the test ends
|
||||
DevToolsUtils.testing = true;
|
||||
registerCleanupFunction(() => DevToolsUtils.testing = false);
|
||||
|
||||
// Clean-up all prefs that might have been changed during a test run
|
||||
// (safer here because if the test fails, then the pref is never reverted)
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref("devtools.dump.emit");
|
||||
Services.prefs.clearUserPref("devtools.debugger.log");
|
||||
});
|
||||
|
||||
|
@ -54,30 +36,17 @@ registerCleanupFunction(() => {
|
|||
* @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 addTab(url) {
|
||||
info("Adding a new tab with URL: '" + url + "'");
|
||||
let def = promise.defer();
|
||||
|
||||
window.focus();
|
||||
|
||||
let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
info("Loading the helper frame script " + FRAME_SCRIPT_URL);
|
||||
browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
|
||||
|
||||
info("Loading the helper frame script " + COMMON_FRAME_SCRIPT_URL);
|
||||
browser.messageManager.loadFrameScript(COMMON_FRAME_SCRIPT_URL, false);
|
||||
|
||||
browser.addEventListener("load", function onload() {
|
||||
browser.removeEventListener("load", onload, true);
|
||||
info("URL '" + url + "' loading complete");
|
||||
|
||||
def.resolve(tab);
|
||||
}, true);
|
||||
|
||||
return def.promise;
|
||||
}
|
||||
var _addTab = addTab;
|
||||
addTab = function(url) {
|
||||
return _addTab(url).then(tab => {
|
||||
let browser = tab.linkedBrowser;
|
||||
info("Loading the helper frame script " + FRAME_SCRIPT_URL);
|
||||
browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
|
||||
info("Loading the helper frame script " + COMMON_FRAME_SCRIPT_URL);
|
||||
browser.messageManager.loadFrameScript(COMMON_FRAME_SCRIPT_URL, false);
|
||||
return tab;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Reload the current tab location.
|
||||
|
@ -91,20 +60,9 @@ function* reloadTab(inspector) {
|
|||
yield inspector.once("inspector-updated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NodeFront for a given css selector, via the protocol
|
||||
* @param {String} selector
|
||||
* @param {InspectorPanel} inspector The instance of InspectorPanel currently
|
||||
* loaded in the toolbox
|
||||
* @return {Promise} Resolves to the NodeFront instance
|
||||
*/
|
||||
function getNodeFront(selector, {walker}) {
|
||||
return walker.querySelector(walker.rootNode, selector);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the inspector's current selection to a node or to the first match of the
|
||||
* given css selector.
|
||||
* given css selector and wait for the animations to be displayed
|
||||
* @param {String|NodeFront}
|
||||
* data The node to select
|
||||
* @param {InspectorPanel} inspector
|
||||
|
@ -114,24 +72,18 @@ function getNodeFront(selector, {walker}) {
|
|||
* Defaults to "test" which instructs the inspector not
|
||||
* to highlight the node upon selection
|
||||
* @return {Promise} Resolves when the inspector is updated with the new node
|
||||
and animations of its subtree are properly displayed.
|
||||
*/
|
||||
var selectNode = Task.async(function*(data, inspector, reason = "test") {
|
||||
info("Selecting the node for '" + data + "'");
|
||||
let nodeFront = data;
|
||||
if (!data._form) {
|
||||
nodeFront = yield getNodeFront(data, inspector);
|
||||
}
|
||||
let updated = inspector.once("inspector-updated");
|
||||
inspector.selection.setNodeFront(nodeFront, reason);
|
||||
yield updated;
|
||||
var selectNodeAndWaitForAnimations = Task.async(
|
||||
function*(data, inspector, reason = "test") {
|
||||
yield selectNode(data, inspector, reason);
|
||||
|
||||
// 99% of the times, selectNode is called to select an animated node, and we
|
||||
// want to make sure the rest of the test waits for the animations to be
|
||||
// properly displayed (wait for all target DOM nodes to be previewed).
|
||||
// Even if there are no animations, this is safe to do.
|
||||
let {AnimationsPanel} = inspector.sidebar.getWindowForTab(TAB_NAME);
|
||||
yield waitForAllAnimationTargets(AnimationsPanel);
|
||||
});
|
||||
// We want to make sure the rest of the test waits for the animations to
|
||||
// be properly displayed (wait for all target DOM nodes to be previewed).
|
||||
let {AnimationsPanel} = inspector.sidebar.getWindowForTab(TAB_NAME);
|
||||
yield waitForAllAnimationTargets(AnimationsPanel);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Check if there are the expected number of animations being displayed in the
|
||||
|
@ -176,23 +128,10 @@ var waitForAnimationInspectorReady = Task.async(function*(inspector) {
|
|||
* @return a promise that resolves when the inspector is ready.
|
||||
*/
|
||||
var openAnimationInspector = Task.async(function*() {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
|
||||
info("Opening the toolbox with the inspector selected");
|
||||
let toolbox = yield gDevTools.showToolbox(target, "inspector");
|
||||
|
||||
info("Switching to the animationinspector");
|
||||
let inspector = toolbox.getPanel("inspector");
|
||||
|
||||
let panelReady = waitForAnimationInspectorReady(inspector);
|
||||
|
||||
info("Waiting for toolbox focus");
|
||||
yield waitForToolboxFrameFocus(toolbox);
|
||||
|
||||
inspector.sidebar.select(TAB_NAME);
|
||||
let {inspector, toolbox} = yield openInspectorSidebarTab(TAB_NAME);
|
||||
|
||||
info("Waiting for the inspector and sidebar to be ready");
|
||||
yield panelReady;
|
||||
yield waitForAnimationInspectorReady(inspector);
|
||||
|
||||
let win = inspector.sidebar.getWindowForTab(TAB_NAME);
|
||||
let {AnimationsController, AnimationsPanel} = win;
|
||||
|
@ -227,60 +166,6 @@ var closeAnimationInspector = Task.async(function*() {
|
|||
yield gDevTools.closeToolbox(target);
|
||||
});
|
||||
|
||||
/**
|
||||
* Wait for the toolbox frame to receive focus after it loads
|
||||
* @param {Toolbox} toolbox
|
||||
* @return a promise that resolves when focus has been received
|
||||
*/
|
||||
function waitForToolboxFrameFocus(toolbox) {
|
||||
info("Making sure that the toolbox's frame is focused");
|
||||
let def = promise.defer();
|
||||
let win = toolbox.frame.contentWindow;
|
||||
waitForFocus(def.resolve, win);
|
||||
return def.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the inspector's sidebar corresponding to the given id already
|
||||
* exists
|
||||
* @param {InspectorPanel}
|
||||
* @param {String}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function hasSideBarTab(inspector, id) {
|
||||
return !!inspector.sidebar.getWindowForTab(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for eventName on target.
|
||||
* @param {Object} target An observable object that either supports on/off or
|
||||
* addEventListener/removeEventListener
|
||||
* @param {String} eventName
|
||||
* @param {Boolean} useCapture Optional, for add/removeEventListener
|
||||
* @return A promise that resolves when the event has been handled
|
||||
*/
|
||||
function once(target, eventName, useCapture = false) {
|
||||
info("Waiting for event: '" + eventName + "' on " + target + ".");
|
||||
|
||||
let deferred = promise.defer();
|
||||
|
||||
for (let [add, remove] of [
|
||||
["addEventListener", "removeEventListener"],
|
||||
["addListener", "removeListener"],
|
||||
["on", "off"]
|
||||
]) {
|
||||
if ((add in target) && (remove in target)) {
|
||||
target[add](eventName, function onEvent(...aArgs) {
|
||||
target[remove](eventName, onEvent, useCapture);
|
||||
deferred.resolve.apply(deferred, aArgs);
|
||||
}, useCapture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a content -> chrome message on the message manager (the window
|
||||
* messagemanager is used).
|
||||
|
|
Загрузка…
Ссылка в новой задаче