summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_rtl.js
blob: 4424df6ea81a3558fc215a49d280a0e5d8d0b552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* 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/. */

"use strict";

// Test that the about:debugging document and the profiler dialog document
// use the expected document direction.
add_task(async function test_direction_is_ltr_by_default() {
  await testAboutDebuggingDocsDirection("ltr");
});

add_task(async function test_direction_is_rtl_for_bidi_pseudolocale() {
  await pushPref("intl.l10n.pseudo", "bidi");
  await testAboutDebuggingDocsDirection("rtl");
});

async function testAboutDebuggingDocsDirection(expectedDir) {
  const mocks = new Mocks();
  const { document, usbClient } = await setupTestForMockUSBRuntime(mocks);

  is(document.dir, expectedDir, "document dir is " + expectedDir);

  info("Open the profiler dialog");
  await openProfilerDialog(usbClient, document);

  const profilerDialogFrame = document.querySelector(
    ".qa-profiler-dialog iframe"
  );
  ok(profilerDialogFrame, "Found Profiler dialog iframe");

  const profilerDoc = profilerDialogFrame.contentWindow.document;
  is(profilerDoc.dir, expectedDir, "Profiler document dir is " + expectedDir);

  await teardownTestForMockUSBRuntime(mocks, document);
}

async function setupTestForMockUSBRuntime(mocks) {
  info("Setup mock USB runtime");

  const usbClient = mocks.createUSBRuntime("runtimeId", {
    deviceName: "deviceName",
    name: "runtimeName",
  });

  info("Open about:debugging and select runtime page for mock USB runtime");
  const { document } = await openAboutDebugging();

  mocks.emitUSBUpdate();
  await connectToRuntime("deviceName", document);
  await selectRuntime("deviceName", "runtimeName", document);

  return { document, usbClient };
}

async function teardownTestForMockUSBRuntime(mocks, doc) {
  info("Remove mock USB runtime");

  mocks.removeUSBRuntime("runtimeId");
  mocks.emitUSBUpdate();
  await waitUntilUsbDeviceIsUnplugged("deviceName", doc);
}