browser_inspector_picker_video_widget.js (1612B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 // Test that the node picker will not trigger video controls when selecting a 8 // video element. 9 10 const TEST_URI = "data:text/html,<video controls>"; 11 12 add_task(async function () { 13 const { inspector, toolbox } = await openInspectorForURL(TEST_URI); 14 const body = await getNodeFront("body", inspector); 15 is( 16 inspector.selection.nodeFront, 17 body, 18 "By default the body node is selected" 19 ); 20 21 info("Start the element picker"); 22 await startPicker(toolbox); 23 24 info("Listen to 'play' events on the <video> element of the test page"); 25 await ContentTask.spawn(gBrowser.selectedBrowser, null, () => { 26 content.wrappedJSObject.testVideoPlayed = false; 27 content.document.querySelector("video").addEventListener("play", () => { 28 content.wrappedJSObject.testVideoPlayed = true; 29 }); 30 }); 31 32 const onSelectionChanged = inspector.once("inspector-updated"); 33 await safeSynthesizeMouseEventAtCenterInContentPage("video"); 34 await onSelectionChanged; 35 36 const videoNodeFront = await getNodeFront("video", inspector); 37 is( 38 inspector.selection.nodeFront, 39 videoNodeFront, 40 "The video element is now selected" 41 ); 42 43 const played = await ContentTask.spawn( 44 gBrowser.selectedBrowser, 45 null, 46 () => content.wrappedJSObject.testVideoPlayed 47 ); 48 ok( 49 !(played === true), 50 "Selecting the video element with the node picker should not play it" 51 ); 52 });