browser_aboutdebugging_rtl.js (2019B)
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 about:debugging document and the profiler dialog document 8 // use the expected document direction. 9 add_task(async function test_direction_is_ltr_by_default() { 10 await testAboutDebuggingDocsDirection("ltr"); 11 }); 12 13 add_task(async function test_direction_is_rtl_for_bidi_pseudolocale() { 14 await pushPref("intl.l10n.pseudo", "bidi"); 15 await testAboutDebuggingDocsDirection("rtl"); 16 }); 17 18 async function testAboutDebuggingDocsDirection(expectedDir) { 19 const mocks = new Mocks(); 20 const { document, usbClient } = await setupTestForMockUSBRuntime(mocks); 21 22 is(document.dir, expectedDir, "document dir is " + expectedDir); 23 24 info("Open the profiler dialog"); 25 await openProfilerDialog(usbClient, document); 26 27 const profilerDialogFrame = document.querySelector( 28 ".qa-profiler-dialog iframe" 29 ); 30 ok(profilerDialogFrame, "Found Profiler dialog iframe"); 31 32 const profilerDoc = profilerDialogFrame.contentWindow.document; 33 is(profilerDoc.dir, expectedDir, "Profiler document dir is " + expectedDir); 34 35 await teardownTestForMockUSBRuntime(mocks, document); 36 } 37 38 async function setupTestForMockUSBRuntime(mocks) { 39 info("Setup mock USB runtime"); 40 41 const usbClient = mocks.createUSBRuntime("runtimeId", { 42 deviceName: "deviceName", 43 name: "runtimeName", 44 }); 45 46 info("Open about:debugging and select runtime page for mock USB runtime"); 47 const { document } = await openAboutDebugging(); 48 49 mocks.emitUSBUpdate(); 50 await connectToRuntime("deviceName", document); 51 await waitForRuntimePage("runtimeName", document); 52 53 return { document, usbClient }; 54 } 55 56 async function teardownTestForMockUSBRuntime(mocks, doc) { 57 info("Remove mock USB runtime"); 58 59 mocks.removeUSBRuntime("runtimeId"); 60 mocks.emitUSBUpdate(); 61 await waitUntilUsbDeviceIsUnplugged("deviceName", doc); 62 }