mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
merge fx-team to mozilla-central a=merge
This commit is contained in:
commit
ebddf3b267
@ -8,6 +8,9 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="mount"></div>
|
||||
<script type="text/javascript">
|
||||
var devtoolsRequire = Components.utils.import("resource://devtools/shared/Loader.jsm", {}).require;
|
||||
</script>
|
||||
<script type="text/javascript" src="resource://devtools/client/debugger/new/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -7,6 +7,11 @@
|
||||
|
||||
const HIGHLIGHTER_TYPE = "EyeDropper";
|
||||
const ID = "eye-dropper-";
|
||||
const TEST_URI = `
|
||||
<style>
|
||||
html{width:100%;height:100%;}
|
||||
</style>
|
||||
<body>eye-dropper test</body>`;
|
||||
|
||||
const MOVE_EVENTS_DATA = [
|
||||
{type: "mouse", x: 200, y: 100, expected: {x: 200, y: 100}},
|
||||
@ -19,26 +24,91 @@ const MOVE_EVENTS_DATA = [
|
||||
{type: "keyboard", key: "VK_DOWN", shift: true, expected: {x: 100, y: 211}},
|
||||
{type: "keyboard", key: "VK_UP", expected: {x: 100, y: 210}},
|
||||
{type: "keyboard", key: "VK_UP", shift: true, expected: {x: 100, y: 200}},
|
||||
// Mouse initialization for left and top snapping
|
||||
{type: "mouse", x: 7, y: 7, expected: {x: 7, y: 7}},
|
||||
// Left Snapping
|
||||
{type: "keyboard", key: "VK_LEFT", shift: true, expected: {x: 0, y: 7},
|
||||
desc: "Left Snapping to x=0"},
|
||||
// Top Snapping
|
||||
{type: "keyboard", key: "VK_UP", shift: true, expected: {x: 0, y: 0},
|
||||
desc: "Top Snapping to y=0"},
|
||||
// Mouse initialization for right snapping
|
||||
{
|
||||
type: "mouse",
|
||||
x: (width, height) => width - 5,
|
||||
y: 0,
|
||||
expected: {
|
||||
x: (width, height) => width - 5,
|
||||
y: 0
|
||||
}
|
||||
},
|
||||
// Right snapping
|
||||
{
|
||||
type: "keyboard",
|
||||
key: "VK_RIGHT",
|
||||
shift: true,
|
||||
expected: {
|
||||
x: (width, height) => width,
|
||||
y: 0
|
||||
},
|
||||
desc: "Right snapping to x=max window width available"
|
||||
},
|
||||
// Mouse initialization for bottom snapping
|
||||
{
|
||||
type: "mouse",
|
||||
x: 0,
|
||||
y: (width, height) => height - 5,
|
||||
expected: {
|
||||
x: 0,
|
||||
y: (width, height) => height - 5
|
||||
}
|
||||
},
|
||||
// Bottom snapping
|
||||
{
|
||||
type: "keyboard",
|
||||
key: "VK_DOWN",
|
||||
shift: true,
|
||||
expected: {
|
||||
x: 0,
|
||||
y: (width, height) => height
|
||||
},
|
||||
desc: "Bottom snapping to y=max window height available"
|
||||
},
|
||||
];
|
||||
|
||||
add_task(function* () {
|
||||
let helper = yield openInspectorForURL("data:text/html;charset=utf-8,eye-dropper test")
|
||||
.then(getHighlighterHelperFor(HIGHLIGHTER_TYPE));
|
||||
let {inspector, testActor} = yield openInspectorForURL(
|
||||
"data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
|
||||
let helper = yield getHighlighterHelperFor(HIGHLIGHTER_TYPE)({inspector, testActor});
|
||||
|
||||
helper.prefix = ID;
|
||||
|
||||
yield helper.show("html");
|
||||
yield respondsToMoveEvents(helper);
|
||||
yield respondsToMoveEvents(helper, testActor);
|
||||
yield respondsToReturnAndEscape(helper);
|
||||
|
||||
helper.finalize();
|
||||
});
|
||||
|
||||
function* respondsToMoveEvents(helper) {
|
||||
function* respondsToMoveEvents(helper, testActor) {
|
||||
info("Checking that the eyedropper responds to events from the mouse and keyboard");
|
||||
let {mouse} = helper;
|
||||
let {width, height} = yield testActor.getBoundingClientRect("html");
|
||||
|
||||
for (let {type, x, y, key, shift, expected, desc} of MOVE_EVENTS_DATA) {
|
||||
x = typeof x === "function" ? x(width, height) : x;
|
||||
y = typeof y === "function" ? y(width, height) : y;
|
||||
expected.x = typeof expected.x === "function" ?
|
||||
expected.x(width, height) : expected.x;
|
||||
expected.y = typeof expected.y === "function" ?
|
||||
expected.y(width, height) : expected.y;
|
||||
|
||||
if (typeof desc === "undefined") {
|
||||
info(`Simulating a ${type} event to move to ${expected.x} ${expected.y}`);
|
||||
} else {
|
||||
info(`Simulating ${type} event: ${desc}`);
|
||||
}
|
||||
|
||||
for (let {type, x, y, key, shift, expected} of MOVE_EVENTS_DATA) {
|
||||
info(`Simulating a ${type} event to move to ${expected.x} ${expected.y}`);
|
||||
if (type === "mouse") {
|
||||
yield mouse.move(x, y);
|
||||
} else if (type === "keyboard") {
|
||||
|
@ -325,6 +325,11 @@
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ruleview-expander.theme-twisty:-moz-locale-dir(rtl) {
|
||||
/* for preventing .theme-twisty's wrong direction in rtl; Bug 1296648 */
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.ruleview-newproperty {
|
||||
/* (enable checkbox width: 12px) + (expander width: 15px) */
|
||||
margin-inline-start: 27px;
|
||||
|
@ -111,7 +111,7 @@ var inputTests = [
|
||||
input: '["' + testStrIn + '", "' + testStrIn + '", "' + testStrIn + '"]',
|
||||
output: 'Array [ "' + testStrOut + '", "' + testStrOut + '", "' +
|
||||
testStrOut + '" ]',
|
||||
inspectable: false,
|
||||
inspectable: true,
|
||||
printOutput: "SHOW\nALL\nOF\nTHIS\nON\nA\nSINGLE\nLINE ONLY. ESCAPE " +
|
||||
"ALL NEWLINE,SHOW\nALL\nOF\nTHIS\nON\nA\nSINGLE\nLINE ONLY. " +
|
||||
"ESCAPE ALL NEWLINE,SHOW\nALL\nOF\nTHIS\nON\nA\nSINGLE\n" +
|
||||
@ -124,7 +124,8 @@ var inputTests = [
|
||||
input: '({0: "a", 1: "b"})',
|
||||
output: 'Object [ "a", "b" ]',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: false,
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object[2]",
|
||||
},
|
||||
|
||||
// 14
|
||||
@ -132,7 +133,8 @@ var inputTests = [
|
||||
input: '({0: "a", 42: "b"})',
|
||||
output: 'Object { 0: "a", 42: "b" }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: false,
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 15
|
||||
@ -165,6 +167,96 @@ var inputTests = [
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 18
|
||||
{
|
||||
input: '({})',
|
||||
output: 'Object { }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 19
|
||||
{
|
||||
input: '({length: 0})',
|
||||
output: 'Object [ ]',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object[0]",
|
||||
},
|
||||
|
||||
// 20
|
||||
{
|
||||
input: '({length: 1})',
|
||||
output: 'Object { length: 1 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 21
|
||||
{
|
||||
input: '({0: "a", 1: "b", length: 1})',
|
||||
output: 'Object { 1: "b", length: 1, 1 more\u2026 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 22
|
||||
{
|
||||
input: '({0: "a", 1: "b", length: 2})',
|
||||
output: 'Object [ "a", "b" ]',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object[2]",
|
||||
},
|
||||
|
||||
// 23
|
||||
{
|
||||
input: '({0: "a", 1: "b", length: 3})',
|
||||
output: 'Object { length: 3, 2 more\u2026 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 24
|
||||
{
|
||||
input: '({0: "a", 2: "b", length: 2})',
|
||||
output: 'Object { 2: "b", length: 2, 1 more\u2026 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 25
|
||||
{
|
||||
input: '({0: "a", 2: "b", length: 3})',
|
||||
output: 'Object { length: 3, 2 more\u2026 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 26
|
||||
{
|
||||
input: '({0: "a", b: "b", length: 1})',
|
||||
output: 'Object { b: "b", length: 1, 1 more\u2026 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
|
||||
// 27
|
||||
{
|
||||
input: '({0: "a", b: "b", length: 2})',
|
||||
output: 'Object { b: "b", length: 2, 1 more\u2026 }',
|
||||
printOutput: "[object Object]",
|
||||
inspectable: true,
|
||||
variablesViewLabel: "Object",
|
||||
},
|
||||
];
|
||||
|
||||
function test() {
|
||||
|
@ -429,8 +429,10 @@ EyeDropper.prototype = {
|
||||
offsetX *= modifier;
|
||||
|
||||
if (offsetX !== 0 || offsetY !== 0) {
|
||||
this.magnifiedArea.x += offsetX;
|
||||
this.magnifiedArea.y += offsetY;
|
||||
this.magnifiedArea.x = cap(this.magnifiedArea.x + offsetX,
|
||||
0, this.win.innerWidth * this.pageZoom);
|
||||
this.magnifiedArea.y = cap(this.magnifiedArea.y + offsetY, 0,
|
||||
this.win.innerHeight * this.pageZoom);
|
||||
|
||||
this.draw();
|
||||
|
||||
@ -526,3 +528,7 @@ function hexString([r, g, b]) {
|
||||
let val = (1 << 24) + (r << 16) + (g << 8) + (b << 0);
|
||||
return "#" + val.toString(16).substr(-6).toUpperCase();
|
||||
}
|
||||
|
||||
function cap(value, min, max) {
|
||||
return Math.max(min, Math.min(value, max));
|
||||
}
|
||||
|
@ -1800,13 +1800,27 @@ DebuggerServer.ObjectActorPreviewers.Object = [
|
||||
return false;
|
||||
}
|
||||
|
||||
// Making sure that all keys are array indices, that is:
|
||||
// `ToString(ToUint32(key)) === key && key !== "4294967295"`.
|
||||
// Also ensuring that the keys are consecutive and start at "0",
|
||||
// this implies checking `key !== "4294967295"` is not necessary.
|
||||
// Pseudo-arrays should only have array indices and, optionally, a "length" property.
|
||||
// Since array indices are sorted first, check if the last property is "length".
|
||||
if(keys[keys.length-1] === "length") {
|
||||
keys.pop();
|
||||
// The value of "length" should equal the number of other properties. If eventually
|
||||
// we allow sparse pseudo-arrays, we should check whether it's a Uint32 instead.
|
||||
if(rawObj.length !== keys.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that the keys are consecutive integers starting at "0". If eventually we
|
||||
// allow sparse pseudo-arrays, we should check that they are array indices, that is:
|
||||
// `(key >>> 0) + '' === key && key !== "4294967295"`.
|
||||
// Checking the last property first allows us to avoid useless iterations when
|
||||
// there is any property which is not an array index.
|
||||
if(keys.length && keys[keys.length-1] !== keys.length - 1 + '') {
|
||||
return false;
|
||||
}
|
||||
for (let key of keys) {
|
||||
let numKey = key >>> 0; // ToUint32(key)
|
||||
if (numKey + '' != key || numKey != length++) {
|
||||
if (key !== (length++) + '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -8538,11 +8538,14 @@ nsDocShell::RestoreFromHistory()
|
||||
int32_t minFontSize = 0;
|
||||
float textZoom = 1.0f;
|
||||
float pageZoom = 1.0f;
|
||||
float overrideDPPX = 0.0f;
|
||||
|
||||
bool styleDisabled = false;
|
||||
if (oldCv && newCv) {
|
||||
oldCv->GetMinFontSize(&minFontSize);
|
||||
oldCv->GetTextZoom(&textZoom);
|
||||
oldCv->GetFullZoom(&pageZoom);
|
||||
oldCv->GetOverrideDPPX(&overrideDPPX);
|
||||
oldCv->GetAuthorStyleDisabled(&styleDisabled);
|
||||
}
|
||||
|
||||
@ -8775,6 +8778,7 @@ nsDocShell::RestoreFromHistory()
|
||||
newCv->SetMinFontSize(minFontSize);
|
||||
newCv->SetTextZoom(textZoom);
|
||||
newCv->SetFullZoom(pageZoom);
|
||||
newCv->SetOverrideDPPX(overrideDPPX);
|
||||
newCv->SetAuthorStyleDisabled(styleDisabled);
|
||||
}
|
||||
|
||||
@ -9268,6 +9272,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
|
||||
int32_t minFontSize;
|
||||
float textZoom;
|
||||
float pageZoom;
|
||||
float overrideDPPX;
|
||||
bool styleDisabled;
|
||||
// |newMUDV| also serves as a flag to set the data from the above vars
|
||||
nsCOMPtr<nsIContentViewer> newCv;
|
||||
@ -9309,6 +9314,8 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(oldCv->GetFullZoom(&pageZoom),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(oldCv->GetOverrideDPPX(&overrideDPPX),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(oldCv->GetAuthorStyleDisabled(&styleDisabled),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
@ -9377,6 +9384,8 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(newCv->SetFullZoom(pageZoom),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(newCv->SetOverrideDPPX(overrideDPPX),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(newCv->SetAuthorStyleDisabled(styleDisabled),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
|
@ -284,6 +284,50 @@ const gTests = {
|
||||
|
||||
setOverrideDPPX(dppx);
|
||||
setFullZoom(zoom);
|
||||
},
|
||||
"test OverrideDPPX is kept on document navigation": (done) => {
|
||||
assertValuesAreInitial();
|
||||
|
||||
let frameOriginalFontSize = getBodyFontSize(frameWindow);
|
||||
let frameStyle = createFontStyleForDPPX(frameWindow.document, dppx, "32");
|
||||
let frameCurrentFontSize = getBodyFontSize(frameWindow);
|
||||
|
||||
is(frameCurrentFontSize, frameOriginalFontSize,
|
||||
"frame's media queries are not applied yet");
|
||||
|
||||
setOverrideDPPX(dppx);
|
||||
|
||||
frameCurrentFontSize = getBodyFontSize(frameWindow);
|
||||
|
||||
is(frameWindow.devicePixelRatio, dppx,
|
||||
"frame's devicePixelRatio overridden.");
|
||||
isnot(frameCurrentFontSize, frameOriginalFontSize,
|
||||
"frame's media queries are applied.");
|
||||
is(frameCurrentFontSize, "32px",
|
||||
"frame's font size has the expected value.");
|
||||
|
||||
frameWindow.frameElement.addEventListener("load", function listener() {
|
||||
this.removeEventListener("load", listener);
|
||||
|
||||
frameStyle = createFontStyleForDPPX(frameWindow.document, dppx, "32");
|
||||
|
||||
frameCurrentFontSize = getBodyFontSize(frameWindow);
|
||||
|
||||
is(frameWindow.devicePixelRatio, dppx,
|
||||
"frame's devicePixelRatio is still overridden.");
|
||||
isnot(frameCurrentFontSize, frameOriginalFontSize,
|
||||
"frame's media queries are still applied.");
|
||||
is(frameCurrentFontSize, "32px",
|
||||
"frame's font size has still the expected value.");
|
||||
|
||||
frameStyle.remove();
|
||||
|
||||
setOverrideDPPX(0);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
frameWindow.location.reload(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user