Files
roytam1 be243367f4 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1060947 - Listing indexedDB databases throws if any of them have 0 objectStores. r=mratcliffe (a880b8d507)
- Bug 1149497 - Wildcard domain cookies are not displayed. r=mratcliffe (76f75dbad2)
- Bug 1261785 - Part 1: fix promise rejections in storage inspector tests. r=mratcliffe (f7c1cb6d4f)
- Bug 1261785 - Part 2: use shared-head.js for storage inspector tests. r=mratcliffe (572c97d806)
- Bug 1261785 - Part 3: make affected JS files eslint-clean. r=mratcliffe (50fd288875)
- Bug 1260380 - 'Parsed value' section gets duplicated when editing. r=mratcliffe (8a2d4952b4)
- Bug 1245615 - Just clear hostVsStores map as some async code may still use them. r=mratcliffe (9e3b3cc05e)
- Bug 1262813 - Fix the getWindowFromHost to allow it gets correct window. r=mratcliffe (97bd327d93)
- Bug 1259169 - nsICookieManager::remove() should be back-compatible, r=jdm (bc3d18286d)
- missing bit of 1235350 (0462aa6c19)
- Bug 1263906 - When starting to edit a storage inspector field, it scrolls away from the view. r=mratcliffe (0497dbe809)
- Bug 1156720 - Firefox freezes when parsing large data in Storage Inspector. r=mratcliffe (4f987d99fa)
- bug 1191889 skip Close() when not initialized r=roc (9bbb78c01e)
- Bug 1254444 - Frame component should react to being focused by displaying a legible color in the memory tool. r=fitzgen (b3c29851ba)
- Bug 1255529 - Make all of a location (source, line, column) clickable/linkable to another tool in the frame component. r=fitzgen,bgrins (2efe045724)
- Bug 1258305 - Pull ViewHelpers.L10N, MultiL10N into their own module, r=jsantell (d511058274)
- Bug 1245875 - Factor out webgl helpers out of tilt. r=vporof (b86b28f7e2)
- Bug 1243561 - fix pretty-printing cache in debugger under certain circumstances r=jryans (c6d5db03bb)
- Bug 1261860 - Prevent exception in debugger UI when processing script with jar: URLs. r=jlongster (bfa8aa2854)
- Bug 1243736 - Enable browser_rules_pseudo-element_02.js with e10s and make rule-view wait for updateSourceLink; r=bgrins (e7aa1d2476)
- Bug 1252346 - Fixes missing Services definition or tweaked eslint to figure out where does it comes from. r=jryans (89f188f259)
- Bug 1240670 - Hide the filter property search for an unmatched rule r=pbro (2dc7ec51ed)
- Bug 1241126 - ruleview: no new-prop editor on prev. editor blur;r=gl (630a522e64)
- Bug 1175319 - Remove outdated MDSM documenation. r=jya DONTBUILD (775d7b1cb4)
- Bug 1265978. Part 1 - add mozDumpDebugInfo() to HTMLMediaElement.webidl. r=bz. (6518ad6a08)
- Bug 1265978. Part 2 - add methods to MediaDecoder and MDSM to dump debugging info. r=jya. (1b8ad138c8)
- Bug 1265978. Part 2.5 - also dump reader data. r=jya. (d866537269)
- Bug 1265978. Part 3 - invoke mozDumpDebugInfo() from JS. r=jya. (7a5a7b5837)
- Bug 1224492 - Modify devtools client inspector to disable commented properties when they are pasted into the rule editor. r=tromey (2888958f3e)
- Bug 1247434 - Move all rep component into shared directory; r=jryans (976e80928b)
- Bug 1219281 - JSON View: Better styling for arrays; r=jryans (b864bb8b0b)
- Bug 1247434 - fix eslint, add comments and remove Locale; r=jryans, pbrosset (4351da017f)
- Bug 1247065 - Implement Tree Component. r=bgrins, r=linclark, r=jlongster (868d55fc0e)
- Bug 1189492 - part1: support horizontal collapsing in ViewHelpers togglePane;r=vporof (6fd726ed4a)
- Bug 1189492 - part2:inspector modify toggle icon to support horizontal layout;r=ntim (05998fa0f6)
- Bug 1189492 - part3: show inspector toggle panel button in SIDE host;r=tromey (0ead5c0452)
2024-06-28 23:06:54 +08:00

102 lines
2.7 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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";
const {Cu, Cc, Ci} = require("chrome");
const Services = require("Services");
const {getMostRecentBrowserWindow} = require("sdk/window/utils");
const OPEN_FLAGS = {
RDONLY: parseInt("0x01"),
WRONLY: parseInt("0x02"),
CREATE_FILE: parseInt("0x08"),
APPEND: parseInt("0x10"),
TRUNCATE: parseInt("0x20"),
EXCL: parseInt("0x80")
};
/**
* Open File Save As dialog and let the user to pick proper file location.
*/
exports.getTargetFile = function() {
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
var win = getMostRecentBrowserWindow();
fp.init(win, null, Ci.nsIFilePicker.modeSave);
fp.appendFilter("JSON Files","*.json; *.jsonp;");
fp.appendFilters(Ci.nsIFilePicker.filterText);
fp.appendFilters(Ci.nsIFilePicker.filterAll);
fp.filterIndex = 0;
var rv = fp.show();
if (rv == Ci.nsIFilePicker.returnOK || rv == Ci.nsIFilePicker.returnReplace) {
return fp.file;
}
return null;
}
/**
* Save JSON to a file
*/
exports.saveToFile = function(file, jsonString) {
var foStream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
// write, create, truncate
let openFlags = OPEN_FLAGS.WRONLY | OPEN_FLAGS.CREATE_FILE |
OPEN_FLAGS.TRUNCATE;
let permFlags = parseInt("0666", 8);
foStream.init(file, openFlags, permFlags, 0);
var converter = Cc["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Ci.nsIConverterOutputStream);
converter.init(foStream, "UTF-8", 0, 0);
// The entire jsonString can be huge so, write the data in chunks.
var chunkLength = 1024*1204;
for (var i=0; i<=jsonString.length; i++) {
var data = jsonString.substr(i, chunkLength+1);
if (data) {
converter.writeString(data);
}
i = i + chunkLength;
}
// this closes foStream
converter.close();
}
/**
* Get the current theme from preferences.
*/
exports.getCurrentTheme = function() {
return Services.prefs.getCharPref("devtools.theme");
}
/**
* Export given object into the target window scope.
*/
exports.exportIntoContentScope = function(win, obj, defineAs) {
var clone = Cu.createObjectIn(win, {
defineAs: defineAs
});
var props = Object.getOwnPropertyNames(obj);
for (var i=0; i<props.length; i++) {
var propName = props[i];
var propValue = obj[propName];
if (typeof propValue == "function") {
Cu.exportFunction(propValue, clone, {
defineAs: propName
});
}
}
}