зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1429254 - Expand long strings when fetching from network monitor. r=jdescottes
In bug 1306892, we started fetching stylesheets from the network monitor when possible. However, this only worked for short strings (< 10000 bytes). For long strings, we need to also look up the long string actor that holds the actual text. MozReview-Commit-ID: 2M0OAioZnX5 --HG-- rename : devtools/client/styleeditor/test/doc_uncached.css => devtools/client/styleeditor/test/doc_short_string.css extra : rebase_source : e0babac9bc162222dc207e9fba3c88b3c22aabfa
This commit is contained in:
Родитель
e7980cdf03
Коммит
4e81bf75f6
|
@ -50,9 +50,10 @@ support-files =
|
|||
sourcemaps-watching.html
|
||||
test_private.css
|
||||
test_private.html
|
||||
doc_fetch_from_netmonitor.html
|
||||
doc_long_string.css
|
||||
doc_long.css
|
||||
doc_uncached.css
|
||||
doc_uncached.html
|
||||
doc_short_string.css
|
||||
doc_xulpage.xul
|
||||
sync.html
|
||||
utf-16.css
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// A test to ensure Style Editor only issues 1 request for a stylesheet (instead of 2) by
|
||||
// using the network monitor's request history (bug 1306892).
|
||||
// A test to ensure Style Editor only issues 1 request for each stylesheet (instead of 2)
|
||||
// by using the network monitor's request history (bug 1306892).
|
||||
|
||||
const TEST_URL = TEST_BASE_HTTP + "doc_uncached.html";
|
||||
const TEST_URL = TEST_BASE_HTTP + "doc_fetch_from_netmonitor.html";
|
||||
|
||||
add_task(function* () {
|
||||
info("Opening netmonitor");
|
||||
|
@ -27,18 +27,27 @@ add_task(function* () {
|
|||
|
||||
info("Opening Style Editor");
|
||||
let styleeditor = yield toolbox.selectTool("styleeditor");
|
||||
let ui = styleeditor.UI;
|
||||
|
||||
info("Waiting for the source to be loaded.");
|
||||
yield styleeditor.UI.editors[0].getSourceEditor();
|
||||
info("Waiting for the sources to be loaded.");
|
||||
yield ui.editors[0].getSourceEditor();
|
||||
yield ui.selectStyleSheet(ui.editors[1].styleSheet);
|
||||
yield ui.editors[1].getSourceEditor();
|
||||
|
||||
info("Checking Netmonitor contents.");
|
||||
let items = [];
|
||||
let shortRequests = [];
|
||||
let longRequests = [];
|
||||
for (let item of getSortedRequests(store.getState())) {
|
||||
if (item.url.endsWith("doc_uncached.css")) {
|
||||
items.push(item);
|
||||
if (item.url.endsWith("doc_short_string.css")) {
|
||||
shortRequests.push(item);
|
||||
}
|
||||
if (item.url.endsWith("doc_long_string.css")) {
|
||||
longRequests.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
is(items.length, 1,
|
||||
"Got one request for doc_uncached.css after Style Editor was loaded.");
|
||||
is(shortRequests.length, 1,
|
||||
"Got one request for doc_short_string.css after Style Editor was loaded.");
|
||||
is(longRequests.length, 1,
|
||||
"Got one request for doc_long_string.css after Style Editor was loaded.");
|
||||
});
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Fetch from netmonitor testcase</title>
|
||||
<link rel="stylesheet" charset="UTF-8" type="text/css" media="screen" href="doc_short_string.css"/>
|
||||
<link rel="stylesheet" charset="UTF-8" type="text/css" media="screen" href="doc_long_string.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div>Fetch from netmonitor</div>
|
||||
</body>
|
||||
</html>
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,10 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>uncached testcase</title>
|
||||
<link rel="stylesheet" charset="UTF-8" type="text/css" media="screen" href="doc_uncached.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div>uncached <span>testcase</span></div>
|
||||
</body>
|
||||
</html>
|
|
@ -494,8 +494,20 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, {
|
|||
if (request._discardResponseBody || !content) {
|
||||
return null;
|
||||
}
|
||||
if (content.text.type != "longString") {
|
||||
// For short strings, the text is available directly.
|
||||
return {
|
||||
content: content.text,
|
||||
contentType: content.mimeType,
|
||||
};
|
||||
}
|
||||
// For long strings, look up the actor that holds the full text.
|
||||
let longStringActor = this.conn._getOrCreateActor(content.text.actor);
|
||||
if (!longStringActor) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
content: content.text,
|
||||
content: longStringActor.rawValue(),
|
||||
contentType: content.mimeType,
|
||||
};
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче