Files
palemoon27/toolkit/devtools/server/tests/browser/browser_stylesheets_getTextEmpty.js
roytam1 0a5fd83fe9 import changes from `dev' branch of rmottola/Arctic-Fox:
- bit of  Bug 1202902 - Fix the world. (b7b307b5b1)
- Bug 1179102 - The async version of loadSubscript doesn't get the right JS version. r=bholley (d390d929f5)
- Bug 1206149 - Use channel->AsyncOpen2() js/xpconnect/loader/mozJSSubScriptLoader.cpp (r=sicking) (0c5b42221d)
- Bug 1185634 - Part 1: SandboxPrivate shouldn't be public. r=gabor (3b63251f58)
- Bug 1185634 - Part 2: Remove obsolete comment. r=gabor (48359ea679)
- some crash reporter and space style (c72b1291a7)
- Bug 1178274 - Ensure the BrowserTabsRemoteAutostart function is first called on the main thread during xpcshell testing. r=billm (3e81414e4a)
- Bug 1186993 - Add MOZ_CHAOSMODE to XPCShell. r=roc (a296f46add)
- Bug 1187410 - Use GetNameShared() in XPCNativeInterface::NewInstance() to avoid a leak. r=mrbkap (54f1496a03)
- var-let (48ada4e8ba)
- Bug 1209077 - handle cached empty string in StyleSheetActor._getText; r=bgrins,pbrosset (1940c70e2e)
2022-10-07 09:52:54 +08:00

43 lines
1.3 KiB
JavaScript

/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that StyleSheetActor.getText handles empty text correctly.
const {StyleSheetsFront} = require("devtools/server/actors/stylesheets");
const CONTENT = "<style>body { background-color: #f0c; }</style>";
const TEST_URI = "data:text/html;charset=utf-8," + encodeURIComponent(CONTENT);
add_task(function*() {
yield addTab(TEST_URI);
info("Initialising the debugger server and client.");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
let form = yield connectDebuggerClient(client);
info("Attaching to the active tab.");
yield new Promise(resolve => {
client.attachTab(form.actor, resolve);
});
let front = StyleSheetsFront(client, form);
ok(front, "The StyleSheetsFront was created.");
let sheets = yield front.getStyleSheets();
ok(sheets, "getStyleSheets() succeeded");
is(sheets.length, 1,
"getStyleSheets() returned the correct number of sheets");
let sheet = sheets[0];
yield sheet.update("", false);
let longStr = yield sheet.getText();
let source = yield longStr.string();
is(source, "", "text is empty");
yield closeDebuggerClient(client);
});