summaryrefslogtreecommitdiffstats
path: root/devtools/client/styleeditor/test/browser_styleeditor_bug_1405342_serviceworker_iframes.js
blob: cccd92fedd2589a8a00a48ed9e7bd6af5a5c15d0 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

// Test that sheets inside cross origin iframes, served from a service worker
// are correctly fetched via the service worker in the stylesheet editor.

add_task(async function () {
  const TEST_URL =
    "https://test1.example.com/browser/devtools/client/styleeditor/test/bug_1405342_serviceworker_iframes.html";
  const { ui } = await openStyleEditorForURL(TEST_URL);

  if (ui.editors.length != 1) {
    info("Stylesheet isn't available immediately, waiting for it");
    await ui.once("editor-added");
  }
  is(ui.editors.length, 1, "Got the iframe stylesheet");

  await ui.selectStyleSheet(ui.editors[0].styleSheet);
  const editor = await ui.editors[0].getSourceEditor();
  const text = editor.sourceEditor.getText();
  is(
    text,
    "* { color: green; }",
    "stylesheet content is the one served by the service worker"
  );
});