forked from mirrors/gecko-dev
Bug 1508987 - Enable ESLint for dom/svg/ (Automatic Changes). r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D22293 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0bdba92de2
commit
9dc9ed699e
65 changed files with 1180 additions and 1346 deletions
|
|
@ -33,12 +33,10 @@
|
|||
// * Event checking can be temporarily disabled with ignoreEvents(). The next
|
||||
// call to expect() will cause it to resume.
|
||||
|
||||
function MutationEventChecker()
|
||||
{
|
||||
function MutationEventChecker() {
|
||||
this.expectedEvents = [];
|
||||
|
||||
this.watchAttr = function(element, attr)
|
||||
{
|
||||
this.watchAttr = function(element, attr) {
|
||||
if (this.attr) {
|
||||
this.finish();
|
||||
}
|
||||
|
|
@ -50,11 +48,10 @@ function MutationEventChecker()
|
|||
this.giveUp = false;
|
||||
this.ignore = false;
|
||||
|
||||
this.element.addEventListener('DOMAttrModified', this._listener);
|
||||
}
|
||||
this.element.addEventListener("DOMAttrModified", this._listener);
|
||||
};
|
||||
|
||||
this.expect = function()
|
||||
{
|
||||
this.expect = function() {
|
||||
if (this.giveUp) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -78,17 +75,16 @@ function MutationEventChecker()
|
|||
// Turn arguments object into an array
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
// Check for whitespace separated keywords
|
||||
if (args.length == 1 && typeof args[0] === 'string' &&
|
||||
args[0].indexOf(' ') > 0) {
|
||||
args = args[0].split(' ');
|
||||
if (args.length == 1 && typeof args[0] === "string" &&
|
||||
args[0].indexOf(" ") > 0) {
|
||||
args = args[0].split(" ");
|
||||
}
|
||||
// Convert strings to event Ids
|
||||
this.expectedEvents = args.map(this._argToEventId);
|
||||
}
|
||||
};
|
||||
|
||||
// Temporarily disable event checking
|
||||
this.ignoreEvents = function()
|
||||
{
|
||||
this.ignoreEvents = function() {
|
||||
// Check all events have been received
|
||||
ok(this.giveUp || this.expectedEvents.length == 0,
|
||||
"Going to ignore subsequent events on " + this.attr +
|
||||
|
|
@ -96,22 +92,20 @@ function MutationEventChecker()
|
|||
this._stillExpecting());
|
||||
|
||||
this.ignore = true;
|
||||
}
|
||||
};
|
||||
|
||||
this.finish = function()
|
||||
{
|
||||
this.finish = function() {
|
||||
// Check all events have been received
|
||||
ok(this.giveUp || this.expectedEvents.length == 0,
|
||||
"Finishing listening to " + this.attr +
|
||||
" attribute, but we're still expecting the following events: " +
|
||||
this._stillExpecting());
|
||||
|
||||
this.element.removeEventListener('DOMAttrModified', this._listener);
|
||||
this.element.removeEventListener("DOMAttrModified", this._listener);
|
||||
this.attr = "";
|
||||
}
|
||||
};
|
||||
|
||||
this._receiveEvent = function(e)
|
||||
{
|
||||
this._receiveEvent = function(e) {
|
||||
if (this.giveUp || this.ignore) {
|
||||
this.oldValue = e.newValue;
|
||||
return;
|
||||
|
|
@ -119,8 +113,8 @@ function MutationEventChecker()
|
|||
|
||||
// Make sure we're expecting something at all
|
||||
if (this.expectedEvents.length == 0) {
|
||||
ok(false, 'Unexpected ' + this._eventToName(e.attrChange) +
|
||||
' event when none expected on ' + this.attr + ' attribute.');
|
||||
ok(false, "Unexpected " + this._eventToName(e.attrChange) +
|
||||
" event when none expected on " + this.attr + " attribute.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -128,9 +122,9 @@ function MutationEventChecker()
|
|||
|
||||
// Make sure we got the event we expected
|
||||
if (e.attrChange != expectedEvent) {
|
||||
ok(false, 'Unexpected ' + this._eventToName(e.attrChange) +
|
||||
' on ' + this.attr + ' attribute. Expected ' +
|
||||
this._eventToName(expectedEvent) + ' (followed by: ' +
|
||||
ok(false, "Unexpected " + this._eventToName(e.attrChange) +
|
||||
" on " + this.attr + " attribute. Expected " +
|
||||
this._eventToName(expectedEvent) + " (followed by: " +
|
||||
this._stillExpecting() + ")");
|
||||
// If we get events out of sequence, it doesn't make sense to do any
|
||||
// further testing since we don't really know what to expect
|
||||
|
|
@ -140,8 +134,8 @@ function MutationEventChecker()
|
|||
|
||||
// Common param checking
|
||||
is(e.target, this.element,
|
||||
'Unexpected node for mutation event on ' + this.attr + ' attribute');
|
||||
is(e.attrName, this.attr, 'Unexpected attribute name for mutation event');
|
||||
"Unexpected node for mutation event on " + this.attr + " attribute");
|
||||
is(e.attrName, this.attr, "Unexpected attribute name for mutation event");
|
||||
|
||||
// Don't bother testing e.relatedNode since Attr nodes are on the way
|
||||
// out anyway (but then, so are mutation events...)
|
||||
|
|
@ -149,60 +143,57 @@ function MutationEventChecker()
|
|||
// Event-specific checking
|
||||
if (e.attrChange == MutationEvent.MODIFICATION) {
|
||||
ok(this.element.hasAttribute(this.attr),
|
||||
'Attribute not set after modification');
|
||||
"Attribute not set after modification");
|
||||
is(e.prevValue, this.oldValue,
|
||||
'Unexpected old value for modification to ' + this.attr +
|
||||
' attribute');
|
||||
"Unexpected old value for modification to " + this.attr +
|
||||
" attribute");
|
||||
isnot(e.newValue, this.oldValue,
|
||||
'Unexpected new value for modification to ' + this.attr +
|
||||
' attribute');
|
||||
"Unexpected new value for modification to " + this.attr +
|
||||
" attribute");
|
||||
} else if (e.attrChange == MutationEvent.REMOVAL) {
|
||||
ok(!this.element.hasAttribute(this.attr), 'Attribute set after removal');
|
||||
ok(!this.element.hasAttribute(this.attr), "Attribute set after removal");
|
||||
is(e.prevValue, this.oldValue,
|
||||
'Unexpected old value for removal of ' + this.attr +
|
||||
' attribute');
|
||||
"Unexpected old value for removal of " + this.attr +
|
||||
" attribute");
|
||||
// DOM 3 Events doesn't say what value newValue will be for a removal
|
||||
// event but generally empty strings are used for other events when an
|
||||
// attribute isn't relevant
|
||||
ok(e.newValue === "",
|
||||
'Unexpected new value for removal of ' + this.attr +
|
||||
' attribute');
|
||||
"Unexpected new value for removal of " + this.attr +
|
||||
" attribute");
|
||||
} else if (e.attrChange == MutationEvent.ADDITION) {
|
||||
ok(this.element.hasAttribute(this.attr),
|
||||
'Attribute not set after addition');
|
||||
"Attribute not set after addition");
|
||||
// DOM 3 Events doesn't say what value prevValue will be for an addition
|
||||
// event but generally empty strings are used for other events when an
|
||||
// attribute isn't relevant
|
||||
ok(e.prevValue === "",
|
||||
'Unexpected old value for addition of ' + this.attr +
|
||||
' attribute');
|
||||
ok(typeof(e.newValue) == 'string' && e.newValue !== "",
|
||||
'Unexpected new value for addition of ' + this.attr +
|
||||
' attribute');
|
||||
"Unexpected old value for addition of " + this.attr +
|
||||
" attribute");
|
||||
ok(typeof(e.newValue) == "string" && e.newValue !== "",
|
||||
"Unexpected new value for addition of " + this.attr +
|
||||
" attribute");
|
||||
} else {
|
||||
ok(false, 'Unexpected mutation event type: ' + e.attrChange);
|
||||
ok(false, "Unexpected mutation event type: " + e.attrChange);
|
||||
this.giveUp = true;
|
||||
}
|
||||
this.oldValue = e.newValue;
|
||||
}
|
||||
};
|
||||
this._listener = this._receiveEvent.bind(this);
|
||||
|
||||
this._stillExpecting = function()
|
||||
{
|
||||
this._stillExpecting = function() {
|
||||
if (this.expectedEvents.length == 0) {
|
||||
return "(nothing)";
|
||||
}
|
||||
var eventNames = [];
|
||||
for (var i=0; i < this.expectedEvents.length; i++) {
|
||||
for (var i = 0; i < this.expectedEvents.length; i++) {
|
||||
eventNames.push(this._eventToName(this.expectedEvents[i]));
|
||||
}
|
||||
return eventNames.join(", ");
|
||||
}
|
||||
};
|
||||
|
||||
this._eventToName = function(evtId)
|
||||
{
|
||||
switch (evtId)
|
||||
{
|
||||
this._eventToName = function(evtId) {
|
||||
switch (evtId) {
|
||||
case MutationEvent.MODIFICATION:
|
||||
return "modification";
|
||||
case MutationEvent.ADDITION:
|
||||
|
|
@ -210,20 +201,18 @@ function MutationEventChecker()
|
|||
case MutationEvent.REMOVAL:
|
||||
return "removal";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this._argToEventId = function(arg)
|
||||
{
|
||||
if (typeof arg === 'number')
|
||||
this._argToEventId = function(arg) {
|
||||
if (typeof arg === "number")
|
||||
return arg;
|
||||
|
||||
if (typeof arg !== 'string') {
|
||||
if (typeof arg !== "string") {
|
||||
ok(false, "Unexpected event type: " + arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (arg.toLowerCase())
|
||||
{
|
||||
switch (arg.toLowerCase()) {
|
||||
case "mod":
|
||||
case "modify":
|
||||
case "modification":
|
||||
|
|
@ -241,5 +230,5 @@ function MutationEventChecker()
|
|||
ok(false, "Unexpected event name: " + arg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
* Utilities for testing SVG matrices
|
||||
*/
|
||||
|
||||
function createMatrix(a, b, c, d, e, f)
|
||||
{
|
||||
function createMatrix(a, b, c, d, e, f) {
|
||||
var svg = document.getElementsByTagName("svg")[0];
|
||||
var m = svg.createSVGMatrix();
|
||||
m.a = a;
|
||||
|
|
@ -22,8 +21,7 @@ function createMatrix(a, b, c, d, e, f)
|
|||
}
|
||||
|
||||
// Lightweight dummy Matrix class for representing arrays that get passed in
|
||||
function MatrixFromArray(a)
|
||||
{
|
||||
function MatrixFromArray(a) {
|
||||
this.a = a[0];
|
||||
this.b = a[1];
|
||||
this.c = a[2];
|
||||
|
|
@ -32,8 +30,7 @@ function MatrixFromArray(a)
|
|||
this.f = a[5];
|
||||
}
|
||||
|
||||
function cmpMatrix(a, b, msg)
|
||||
{
|
||||
function cmpMatrix(a, b, msg) {
|
||||
if (a.constructor === Array)
|
||||
a = new MatrixFromArray(a);
|
||||
if (b.constructor === Array)
|
||||
|
|
@ -49,8 +46,7 @@ function cmpMatrix(a, b, msg)
|
|||
+ ", expected " + formatMatrix(b));
|
||||
}
|
||||
|
||||
function roughCmpMatrix(a, b, msg)
|
||||
{
|
||||
function roughCmpMatrix(a, b, msg) {
|
||||
if (a.constructor === Array)
|
||||
a = new MatrixFromArray(a);
|
||||
if (b.constructor === Array)
|
||||
|
|
@ -67,10 +63,9 @@ function roughCmpMatrix(a, b, msg)
|
|||
+ ", expected " + formatMatrix(b));
|
||||
}
|
||||
|
||||
function formatMatrix(m)
|
||||
{
|
||||
function formatMatrix(m) {
|
||||
if (m.constructor != Array)
|
||||
return "(" + [m.a, m.b, m.c, m.d, m.e, m.f].join(', ') + ")";
|
||||
return "(" + [m.a, m.b, m.c, m.d, m.e, m.f].join(", ") + ")";
|
||||
|
||||
return "(" + m.join(', ') + ")";
|
||||
return "(" + m.join(", ") + ")";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var pointer_events_values = [
|
||||
'auto',
|
||||
'visiblePainted',
|
||||
'visibleFill',
|
||||
'visibleStroke',
|
||||
'visible',
|
||||
'painted',
|
||||
'fill',
|
||||
'stroke',
|
||||
'all',
|
||||
'none'
|
||||
"auto",
|
||||
"visiblePainted",
|
||||
"visibleFill",
|
||||
"visibleStroke",
|
||||
"visible",
|
||||
"painted",
|
||||
"fill",
|
||||
"stroke",
|
||||
"all",
|
||||
"none",
|
||||
];
|
||||
|
||||
var paint_values = [
|
||||
'blue',
|
||||
'transparent',
|
||||
'none'
|
||||
"blue",
|
||||
"transparent",
|
||||
"none",
|
||||
];
|
||||
|
||||
var opacity_values = [
|
||||
'1',
|
||||
'0.5',
|
||||
'0'
|
||||
"1",
|
||||
"0.5",
|
||||
"0",
|
||||
];
|
||||
|
||||
var visibility_values = [
|
||||
'visible',
|
||||
'hidden',
|
||||
'collapse'
|
||||
"visible",
|
||||
"hidden",
|
||||
"collapse",
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -43,29 +43,29 @@ var visibility_values = [
|
|||
*/
|
||||
var hit_test_inputs = {
|
||||
fill: [
|
||||
{ name: 'pointer-events', values: pointer_events_values },
|
||||
{ name: 'fill', values: paint_values },
|
||||
{ name: 'fill-opacity', values: opacity_values },
|
||||
{ name: 'opacity', values: opacity_values },
|
||||
{ name: 'visibility', values: visibility_values }
|
||||
{ name: "pointer-events", values: pointer_events_values },
|
||||
{ name: "fill", values: paint_values },
|
||||
{ name: "fill-opacity", values: opacity_values },
|
||||
{ name: "opacity", values: opacity_values },
|
||||
{ name: "visibility", values: visibility_values },
|
||||
],
|
||||
stroke: [
|
||||
{ name: 'pointer-events', values: pointer_events_values },
|
||||
{ name: 'stroke', values: paint_values },
|
||||
{ name: 'stroke-opacity', values: opacity_values },
|
||||
{ name: 'opacity', values: opacity_values },
|
||||
{ name: 'visibility', values: visibility_values }
|
||||
{ name: "pointer-events", values: pointer_events_values },
|
||||
{ name: "stroke", values: paint_values },
|
||||
{ name: "stroke-opacity", values: opacity_values },
|
||||
{ name: "opacity", values: opacity_values },
|
||||
{ name: "visibility", values: visibility_values },
|
||||
],
|
||||
both: [
|
||||
{ name: 'pointer-events', values: pointer_events_values },
|
||||
{ name: 'fill', values: paint_values },
|
||||
{ name: 'fill-opacity', values: opacity_values },
|
||||
{ name: 'stroke', values: paint_values },
|
||||
{ name: 'stroke-opacity', values: opacity_values },
|
||||
{ name: 'opacity', values: opacity_values },
|
||||
{ name: 'visibility', values: visibility_values }
|
||||
]
|
||||
}
|
||||
{ name: "pointer-events", values: pointer_events_values },
|
||||
{ name: "fill", values: paint_values },
|
||||
{ name: "fill-opacity", values: opacity_values },
|
||||
{ name: "stroke", values: paint_values },
|
||||
{ name: "stroke-opacity", values: opacity_values },
|
||||
{ name: "opacity", values: opacity_values },
|
||||
{ name: "visibility", values: visibility_values },
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* The following object contains a list of 'pointer-events' property values,
|
||||
|
|
@ -86,77 +86,77 @@ var hit_test_inputs = {
|
|||
*/
|
||||
var hit_conditions = {
|
||||
auto: {
|
||||
'fill-intercepts-iff': {
|
||||
'visibility': ['visible'],
|
||||
'fill!': ['none']
|
||||
"fill-intercepts-iff": {
|
||||
"visibility": ["visible"],
|
||||
"fill!": ["none"],
|
||||
},
|
||||
"stroke-intercepts-iff": {
|
||||
"visibility": ["visible"],
|
||||
"stroke!": ["none"],
|
||||
},
|
||||
'stroke-intercepts-iff': {
|
||||
'visibility': ['visible'],
|
||||
'stroke!': ['none']
|
||||
}
|
||||
},
|
||||
visiblePainted: {
|
||||
'fill-intercepts-iff': {
|
||||
'visibility': ['visible'],
|
||||
'fill!': ['none']
|
||||
"fill-intercepts-iff": {
|
||||
"visibility": ["visible"],
|
||||
"fill!": ["none"],
|
||||
},
|
||||
"stroke-intercepts-iff": {
|
||||
"visibility": ["visible"],
|
||||
"stroke!": ["none"],
|
||||
},
|
||||
'stroke-intercepts-iff': {
|
||||
'visibility': ['visible'],
|
||||
'stroke!': ['none']
|
||||
}
|
||||
},
|
||||
visibleFill: {
|
||||
'fill-intercepts-iff': {
|
||||
visibility: ['visible']
|
||||
}
|
||||
"fill-intercepts-iff": {
|
||||
visibility: ["visible"],
|
||||
},
|
||||
// stroke never intercepts pointer events
|
||||
},
|
||||
visibleStroke: {
|
||||
// fill never intercepts pointer events
|
||||
'stroke-intercepts-iff': {
|
||||
visibility: ['visible']
|
||||
}
|
||||
"stroke-intercepts-iff": {
|
||||
visibility: ["visible"],
|
||||
},
|
||||
},
|
||||
visible: {
|
||||
'fill-intercepts-iff': {
|
||||
visibility: ['visible']
|
||||
"fill-intercepts-iff": {
|
||||
visibility: ["visible"],
|
||||
},
|
||||
"stroke-intercepts-iff": {
|
||||
visibility: ["visible"],
|
||||
},
|
||||
'stroke-intercepts-iff': {
|
||||
visibility: ['visible']
|
||||
}
|
||||
},
|
||||
painted: {
|
||||
'fill-intercepts-iff': {
|
||||
'fill!': ['none']
|
||||
"fill-intercepts-iff": {
|
||||
"fill!": ["none"],
|
||||
},
|
||||
"stroke-intercepts-iff": {
|
||||
"stroke!": ["none"],
|
||||
},
|
||||
'stroke-intercepts-iff': {
|
||||
'stroke!': ['none']
|
||||
}
|
||||
},
|
||||
fill: {
|
||||
'fill-intercepts-iff': {
|
||||
"fill-intercepts-iff": {
|
||||
// fill always intercepts pointer events
|
||||
}
|
||||
},
|
||||
// stroke never intercepts pointer events
|
||||
},
|
||||
stroke: {
|
||||
// fill never intercepts pointer events
|
||||
'stroke-intercepts-iff': {
|
||||
"stroke-intercepts-iff": {
|
||||
// stroke always intercepts pointer events
|
||||
}
|
||||
},
|
||||
},
|
||||
all: {
|
||||
'fill-intercepts-iff': {
|
||||
"fill-intercepts-iff": {
|
||||
// fill always intercepts pointer events
|
||||
},
|
||||
'stroke-intercepts-iff': {
|
||||
"stroke-intercepts-iff": {
|
||||
// stroke always intercepts pointer events
|
||||
}
|
||||
},
|
||||
},
|
||||
none: {
|
||||
// neither fill nor stroke intercept pointer events
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// bit flags
|
||||
var POINT_OVER_FILL = 0x1;
|
||||
|
|
@ -167,22 +167,21 @@ var POINT_OVER_STROKE = 0x2;
|
|||
* element that the pointer event is over (fill and/or stroke areas), return
|
||||
* true if the element is expected to intercept the event, otherwise false.
|
||||
*/
|
||||
function hit_expected(element, over /* bit flags indicating which area(s) of the element the pointer is over */)
|
||||
{
|
||||
function expect_hit(target){
|
||||
function hit_expected(element, over /* bit flags indicating which area(s) of the element the pointer is over */) {
|
||||
function expect_hit(target) {
|
||||
var intercepts_iff =
|
||||
hit_conditions[element.getAttribute('pointer-events')][target + '-intercepts-iff'];
|
||||
hit_conditions[element.getAttribute("pointer-events")][target + "-intercepts-iff"];
|
||||
|
||||
if (!intercepts_iff) {
|
||||
return false; // never intercepts events
|
||||
}
|
||||
|
||||
for (var attr in intercepts_iff) {
|
||||
var vals = intercepts_iff[attr]; // must get this before we adjust 'attr'
|
||||
var vals = intercepts_iff[attr]; // must get this before we adjust 'attr'
|
||||
var invert = false;
|
||||
if (attr.substr(-1) == '!') {
|
||||
if (attr.substr(-1) == "!") {
|
||||
invert = true;
|
||||
attr = attr.substr(0, attr.length-1);
|
||||
attr = attr.substr(0, attr.length - 1);
|
||||
}
|
||||
var match = vals.indexOf(element.getAttribute(attr)) > -1;
|
||||
if (invert) {
|
||||
|
|
@ -196,12 +195,11 @@ function hit_expected(element, over /* bit flags indicating which area(s) of the
|
|||
return true;
|
||||
}
|
||||
|
||||
return (over & POINT_OVER_FILL) != 0 && expect_hit('fill') ||
|
||||
(over & POINT_OVER_STROKE) != 0 && expect_hit('stroke');
|
||||
return (over & POINT_OVER_FILL) != 0 && expect_hit("fill") ||
|
||||
(over & POINT_OVER_STROKE) != 0 && expect_hit("stroke");
|
||||
}
|
||||
|
||||
function for_all_permutations(inputs, callback)
|
||||
{
|
||||
function for_all_permutations(inputs, callback) {
|
||||
var current_permutation = arguments[2] || {};
|
||||
var index = arguments[3] || 0;
|
||||
|
||||
|
|
@ -210,7 +208,7 @@ function for_all_permutations(inputs, callback)
|
|||
var values = inputs[index].values;
|
||||
for (var i = 0; i < values.length; ++i) {
|
||||
current_permutation[name] = values[i];
|
||||
for_all_permutations(inputs, callback, current_permutation, index+1);
|
||||
for_all_permutations(inputs, callback, current_permutation, index + 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -218,29 +216,27 @@ function for_all_permutations(inputs, callback)
|
|||
callback(current_permutation);
|
||||
}
|
||||
|
||||
function make_log_msg(over, tag, attributes)
|
||||
{
|
||||
function make_log_msg(over, tag, attributes) {
|
||||
var target;
|
||||
if (over == (POINT_OVER_FILL | POINT_OVER_STROKE)) {
|
||||
target = 'fill and stroke';
|
||||
target = "fill and stroke";
|
||||
} else if (over == POINT_OVER_FILL) {
|
||||
target = 'fill';
|
||||
target = "fill";
|
||||
} else if (over == POINT_OVER_STROKE) {
|
||||
target = 'stroke';
|
||||
target = "stroke";
|
||||
} else {
|
||||
throw "unexpected bit combination in 'over'";
|
||||
}
|
||||
var msg = 'Check if events are intercepted at a point over the '+target+' on <'+tag+'> for';
|
||||
var msg = "Check if events are intercepted at a point over the " + target + " on <" + tag + "> for";
|
||||
for (var attr in attributes) {
|
||||
msg += ' '+attr+'='+attributes[attr];
|
||||
msg += " " + attr + "=" + attributes[attr];
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
var dx, dy; // offset of <svg> element from pointer coordinates origin
|
||||
|
||||
function test_element(id, x, y, over /* bit flags indicating which area(s) of the element the pointer is over */)
|
||||
{
|
||||
function test_element(id, x, y, over /* bit flags indicating which area(s) of the element the pointer is over */) {
|
||||
var element = document.getElementById(id);
|
||||
var tag = element.tagName;
|
||||
|
||||
|
|
@ -256,11 +252,11 @@ function test_element(id, x, y, over /* bit flags indicating which area(s) of th
|
|||
|
||||
var inputs;
|
||||
if (over == (POINT_OVER_FILL | POINT_OVER_STROKE)) {
|
||||
inputs = hit_test_inputs['both'];
|
||||
inputs = hit_test_inputs.both;
|
||||
} else if (over == POINT_OVER_FILL) {
|
||||
inputs = hit_test_inputs['fill'];
|
||||
inputs = hit_test_inputs.fill;
|
||||
} else if (over == POINT_OVER_STROKE) {
|
||||
inputs = hit_test_inputs['stroke'];
|
||||
inputs = hit_test_inputs.stroke;
|
||||
} else {
|
||||
throw "unexpected bit combination in 'over'";
|
||||
}
|
||||
|
|
@ -268,12 +264,11 @@ function test_element(id, x, y, over /* bit flags indicating which area(s) of th
|
|||
for_all_permutations(inputs, test_permutation);
|
||||
|
||||
// To reduce the chance of bogus results in subsequent tests:
|
||||
element.setAttribute('fill', 'none');
|
||||
element.setAttribute('stroke', 'none');
|
||||
element.setAttribute("fill", "none");
|
||||
element.setAttribute("stroke", "none");
|
||||
}
|
||||
|
||||
function run_tests(subtest)
|
||||
{
|
||||
function run_tests(subtest) {
|
||||
var div = document.getElementById("div");
|
||||
dx = div.offsetLeft;
|
||||
dy = div.offsetTop;
|
||||
|
|
@ -294,8 +289,8 @@ function run_tests(subtest)
|
|||
throw "unexpected subtest number";
|
||||
}
|
||||
|
||||
test_element('rect', 30, 30, POINT_OVER_FILL);
|
||||
test_element('rect', 5, 5, POINT_OVER_STROKE);
|
||||
test_element("rect", 30, 30, POINT_OVER_FILL);
|
||||
test_element("rect", 5, 5, POINT_OVER_STROKE);
|
||||
|
||||
// The SVG 1.1 spec essentially says that, for text, hit testing is done
|
||||
// against the character cells of the text, and not the fill and stroke as
|
||||
|
|
@ -322,7 +317,7 @@ function run_tests(subtest)
|
|||
// intercept events in the normal way. When we make that change we'll be able
|
||||
// to add separate fill and stroke tests for text below.
|
||||
|
||||
test_element('text', 210, 30, POINT_OVER_FILL | POINT_OVER_STROKE);
|
||||
test_element("text", 210, 30, POINT_OVER_FILL | POINT_OVER_STROKE);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=630760
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run_tests()
|
||||
{
|
||||
var svg = document.getElementById('svg');
|
||||
function run_tests() {
|
||||
var svg = document.getElementById("svg");
|
||||
svg.pauseAnimations();
|
||||
|
||||
// Check that the animVal list for 'x' on <text> gives the correct number of
|
||||
|
|
@ -34,7 +33,7 @@ function run_tests()
|
|||
var text = document.getElementById("text");
|
||||
var list = text.x.animVal;
|
||||
|
||||
is(list.numberOfItems, 4, 'Checking numberOfItems');
|
||||
is(list.numberOfItems, 4, "Checking numberOfItems");
|
||||
|
||||
// Check that items at an index larger than 255 (max value for PRUint8) are
|
||||
// returning the correct values:
|
||||
|
|
@ -50,8 +49,8 @@ function run_tests()
|
|||
item.value = 2;
|
||||
list.appendItem(item);
|
||||
|
||||
is(list.getItem(0).value, 1, 'Check value of first item');
|
||||
is(list.getItem(256).value, 2, 'Check value of item at index > 255');
|
||||
is(list.getItem(0).value, 1, "Check value of first item");
|
||||
is(list.getItem(256).value, 2, "Check value of item at index > 255");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,13 @@ tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
|
|||
to other list types belongs there.
|
||||
*/
|
||||
|
||||
function run_tests()
|
||||
{
|
||||
document.getElementById('svg').pauseAnimations();
|
||||
function run_tests() {
|
||||
document.getElementById("svg").pauseAnimations();
|
||||
|
||||
var text = document.getElementById("text");
|
||||
var lengths = text.x.baseVal;
|
||||
|
||||
is(lengths.numberOfItems, 0, 'Checking numberOfItems');
|
||||
is(lengths.numberOfItems, 0, "Checking numberOfItems");
|
||||
|
||||
// Test mutation events
|
||||
// --- Initialization
|
||||
|
|
@ -46,7 +45,7 @@ function run_tests()
|
|||
eventChecker.expect("modify");
|
||||
text.textContent = "abc";
|
||||
text.setAttribute("x", "10 20 30");
|
||||
is(lengths.numberOfItems, 3, 'Checking numberOfItems');
|
||||
is(lengths.numberOfItems, 3, "Checking numberOfItems");
|
||||
// -- Actual changes
|
||||
eventChecker.expect("modify modify modify modify modify");
|
||||
lengths[0].value = 8;
|
||||
|
|
@ -66,7 +65,7 @@ function run_tests()
|
|||
// -- Invalid attribute
|
||||
eventChecker.expect("modify");
|
||||
text.setAttribute("x", ",20");
|
||||
is(lengths.numberOfItems, 0, 'Checking that parsing stops at invalid token');
|
||||
is(lengths.numberOfItems, 0, "Checking that parsing stops at invalid token");
|
||||
// -- Attribute removal
|
||||
eventChecker.expect("remove");
|
||||
text.removeAttribute("x");
|
||||
|
|
@ -96,7 +95,7 @@ function run_tests()
|
|||
function appendItem(aItem) {
|
||||
text.removeAttribute("x");
|
||||
return lengths.appendItem(aItem);
|
||||
}
|
||||
},
|
||||
];
|
||||
subtests.forEach(function(aFunction) {
|
||||
// -- Adding an unowned SVGLength
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function main()
|
||||
{
|
||||
function main() {
|
||||
var tests =
|
||||
[ testCreateMatrix,
|
||||
testMultiply,
|
||||
|
|
@ -32,7 +31,7 @@ function main()
|
|||
testFlipX,
|
||||
testFlipY,
|
||||
testSkewX,
|
||||
testSkewY
|
||||
testSkewY,
|
||||
];
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
tests[i]();
|
||||
|
|
@ -40,9 +39,8 @@ function main()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testCreateMatrix()
|
||||
{
|
||||
svg = $('svg');
|
||||
function testCreateMatrix() {
|
||||
svg = $("svg");
|
||||
var m = svg.createSVGMatrix();
|
||||
|
||||
// Should be initialised to identity
|
||||
|
|
@ -55,8 +53,7 @@ function testCreateMatrix()
|
|||
}
|
||||
|
||||
// SVGMatrix multiply(in SVGMatrix secondMatrix);
|
||||
function testMultiply()
|
||||
{
|
||||
function testMultiply() {
|
||||
// This is the example from SVG 1.1 section 7.5
|
||||
var m1 = createMatrix(1, 0, 0, 1, 50, 90);
|
||||
var m2 = createMatrix(0.707, -0.707, 0.707, 0.707, 0, 0);
|
||||
|
|
@ -73,8 +70,7 @@ function testMultiply()
|
|||
}
|
||||
|
||||
// SVGMatrix inverse() raises(SVGException);
|
||||
function testInverse()
|
||||
{
|
||||
function testInverse() {
|
||||
// Test inversion
|
||||
var m = createMatrix(2, 0, 0, 4, 110, -50);
|
||||
roughCmpMatrix(m.inverse(), [0.5, 0, 0, 0.25, -55, 12.5],
|
||||
|
|
@ -92,49 +88,44 @@ function testInverse()
|
|||
}
|
||||
|
||||
// SVGMatrix translate(in float x, in float y);
|
||||
function testTranslate()
|
||||
{
|
||||
function testTranslate() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
roughCmpMatrix(m.translate(100, -50), [2, 0, 0, 1, 320, 50],
|
||||
"Unexpected result after translate");
|
||||
}
|
||||
|
||||
// SVGMatrix scale(in float scaleFactor);
|
||||
function testScale()
|
||||
{
|
||||
function testScale() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
roughCmpMatrix(m.scale(0.5), [1, 0, 0, 0.5, 120, 100],
|
||||
"Unexpected result after scale");
|
||||
}
|
||||
|
||||
// SVGMatrix scaleNonUniform(in float scaleFactorX, in float scaleFactorY);
|
||||
function testScaleNonUniform()
|
||||
{
|
||||
function testScaleNonUniform() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
roughCmpMatrix(m.scaleNonUniform(0.5, -3), [1, 0, 0, -3, 120, 100],
|
||||
"Unexpected result after scaleNonUniform");
|
||||
}
|
||||
|
||||
// SVGMatrix rotate(in float angle);
|
||||
function testRotate()
|
||||
{
|
||||
function testRotate() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
roughCmpMatrix(m.rotate(45),
|
||||
[2*Math.cos(Math.PI/4), Math.sin(Math.PI/4),
|
||||
2*-Math.sin(Math.PI/4), Math.cos(Math.PI/4),
|
||||
[2 * Math.cos(Math.PI / 4), Math.sin(Math.PI / 4),
|
||||
2 * -Math.sin(Math.PI / 4), Math.cos(Math.PI / 4),
|
||||
120, 100],
|
||||
"Unexpected result after rotate");
|
||||
}
|
||||
|
||||
// SVGMatrix rotateFromVector(in float x, in float y) raises(SVGException);
|
||||
function testRotateFromVector()
|
||||
{
|
||||
function testRotateFromVector() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
// Make a 150 degree angle
|
||||
var result = m.rotateFromVector(-2, 1.1547);
|
||||
roughCmpMatrix(result,
|
||||
[2*Math.cos(5*Math.PI/6), Math.sin(5*Math.PI/6),
|
||||
2*-Math.sin(5*Math.PI/6), Math.cos(5*Math.PI/6),
|
||||
[2 * Math.cos(5 * Math.PI / 6), Math.sin(5 * Math.PI / 6),
|
||||
2 * -Math.sin(5 * Math.PI / 6), Math.cos(5 * Math.PI / 6),
|
||||
120, 100],
|
||||
"Unexpected result after rotateFromVector");
|
||||
|
||||
|
|
@ -155,32 +146,28 @@ function testRotateFromVector()
|
|||
}
|
||||
|
||||
// SVGMatrix flipX();
|
||||
function testFlipX()
|
||||
{
|
||||
function testFlipX() {
|
||||
var m = createMatrix(1, 2, 3, 4, 5, 6);
|
||||
cmpMatrix(m.flipX(), [-1, -2, 3, 4, 5, 6], "Unexpected result after flipX");
|
||||
}
|
||||
|
||||
// SVGMatrix flipY();
|
||||
function testFlipY()
|
||||
{
|
||||
function testFlipY() {
|
||||
var m = createMatrix(1, 2, 3, 4, 5, 6);
|
||||
cmpMatrix(m.flipY(), [1, 2, -3, -4, 5, 6], "Unexpected result after flipY");
|
||||
}
|
||||
|
||||
// SVGMatrix skewX(in float angle);
|
||||
function testSkewX()
|
||||
{
|
||||
function testSkewX() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
roughCmpMatrix(m.skewX(30), [2, 0, 2*Math.tan(Math.PI/6), 1, 120, 100],
|
||||
roughCmpMatrix(m.skewX(30), [2, 0, 2 * Math.tan(Math.PI / 6), 1, 120, 100],
|
||||
"Unexpected result after skewX");
|
||||
}
|
||||
|
||||
// SVGMatrix skewY(in float angle);
|
||||
function testSkewY()
|
||||
{
|
||||
function testSkewY() {
|
||||
var m = createMatrix(2, 0, 0, 1, 120, 100);
|
||||
roughCmpMatrix(m.skewY(30), [2, Math.tan(Math.PI/6), 0, 1, 120, 100],
|
||||
roughCmpMatrix(m.skewY(30), [2, Math.tan(Math.PI / 6), 0, 1, 120, 100],
|
||||
"Unexpected result after skewY");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,14 +28,13 @@ tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
|
|||
to other list types belongs there.
|
||||
*/
|
||||
|
||||
function run_tests()
|
||||
{
|
||||
document.getElementById('svg').pauseAnimations();
|
||||
function run_tests() {
|
||||
document.getElementById("svg").pauseAnimations();
|
||||
|
||||
var text = document.getElementById("text");
|
||||
var numbers = text.rotate.baseVal;
|
||||
|
||||
is(numbers.numberOfItems, 3, 'Checking numberOfItems');
|
||||
is(numbers.numberOfItems, 3, "Checking numberOfItems");
|
||||
|
||||
// Test mutation events
|
||||
// --- Initialization
|
||||
|
|
@ -53,7 +52,7 @@ function run_tests()
|
|||
// -- Invalid attribute
|
||||
eventChecker.expect("modify");
|
||||
text.setAttribute("rotate", ",20");
|
||||
is(numbers.numberOfItems, 0, 'Checking that parsing stops at invalid token');
|
||||
is(numbers.numberOfItems, 0, "Checking that parsing stops at invalid token");
|
||||
// -- Attribute removal
|
||||
eventChecker.expect("remove");
|
||||
text.removeAttribute("rotate");
|
||||
|
|
|
|||
|
|
@ -29,14 +29,13 @@ tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
|
|||
to other list types belongs there.
|
||||
*/
|
||||
|
||||
function run_tests()
|
||||
{
|
||||
document.getElementById('svg').pauseAnimations();
|
||||
function run_tests() {
|
||||
document.getElementById("svg").pauseAnimations();
|
||||
|
||||
var polyline = document.getElementById("polyline");
|
||||
var points = polyline.points;
|
||||
|
||||
is(points.numberOfItems, 2, 'Checking numberOfItems');
|
||||
is(points.numberOfItems, 2, "Checking numberOfItems");
|
||||
|
||||
// Test mutation events
|
||||
// --- Initialization
|
||||
|
|
@ -54,7 +53,7 @@ function run_tests()
|
|||
// -- Invalid attribute
|
||||
eventChecker.expect("modify");
|
||||
polyline.setAttribute("points", ",30,375");
|
||||
is(points.numberOfItems, 0, 'Checking that parsing stops at invalid token');
|
||||
is(points.numberOfItems, 0, "Checking that parsing stops at invalid token");
|
||||
// -- Attribute removal
|
||||
eventChecker.expect("remove");
|
||||
polyline.removeAttribute("points");
|
||||
|
|
@ -83,7 +82,7 @@ function run_tests()
|
|||
function appendItem(aItem) {
|
||||
polyline.removeAttribute("points");
|
||||
return points.appendItem(aItem);
|
||||
}
|
||||
},
|
||||
];
|
||||
subtests.forEach(function(aFunction) {
|
||||
// -- Adding SVGSVGElement.currentTranslate, which is the only instance
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
|
|||
to other list types belongs there.
|
||||
*/
|
||||
|
||||
function initializeThrowsFor(stringList, value)
|
||||
{
|
||||
function initializeThrowsFor(stringList, value) {
|
||||
try {
|
||||
stringList.initialize(value);
|
||||
} catch (e) {
|
||||
|
|
@ -36,8 +35,7 @@ function initializeThrowsFor(stringList, value)
|
|||
return false;
|
||||
}
|
||||
|
||||
function insertItemBeforeThrowsFor(stringList, value)
|
||||
{
|
||||
function insertItemBeforeThrowsFor(stringList, value) {
|
||||
try {
|
||||
stringList.insertItemBefore(value, 0);
|
||||
} catch (e) {
|
||||
|
|
@ -46,8 +44,7 @@ function insertItemBeforeThrowsFor(stringList, value)
|
|||
return false;
|
||||
}
|
||||
|
||||
function replaceItemThrowsFor(stringList, value)
|
||||
{
|
||||
function replaceItemThrowsFor(stringList, value) {
|
||||
try {
|
||||
stringList.replaceItem(value, 0);
|
||||
} catch (e) {
|
||||
|
|
@ -56,8 +53,7 @@ function replaceItemThrowsFor(stringList, value)
|
|||
return false;
|
||||
}
|
||||
|
||||
function appendItemThrowsFor(stringList, value)
|
||||
{
|
||||
function appendItemThrowsFor(stringList, value) {
|
||||
try {
|
||||
stringList.appendItem(value);
|
||||
} catch (e) {
|
||||
|
|
@ -66,38 +62,37 @@ function appendItemThrowsFor(stringList, value)
|
|||
return false;
|
||||
}
|
||||
|
||||
function run_tests()
|
||||
{
|
||||
function run_tests() {
|
||||
var g = document.getElementById("g");
|
||||
var strings = g.requiredFeatures;
|
||||
|
||||
// sanity check:
|
||||
is(strings.numberOfItems, 3, 'numberOfItems should be 3');
|
||||
is(strings.numberOfItems, 3, "numberOfItems should be 3");
|
||||
|
||||
|
||||
ok(!initializeThrowsFor(strings, null),
|
||||
"SVGStringList.initialize() should not throw when passed null");
|
||||
ok(initializeThrowsFor(strings, ""),
|
||||
"SVGStringList.initialize() should throw when passed the empty string");
|
||||
is(strings.length, 0, 'length should be 0');
|
||||
is(strings.length, 0, "length should be 0");
|
||||
|
||||
ok(!insertItemBeforeThrowsFor(strings, null),
|
||||
"SVGStringList.insertItemBefore() should not throw when passed null");
|
||||
ok(insertItemBeforeThrowsFor(strings, ""),
|
||||
ok(insertItemBeforeThrowsFor(strings, ""),
|
||||
"SVGStringList.insertItemBefore() should throw when passed the empty string");
|
||||
is(strings.length, 1, 'length should be 1');
|
||||
is(strings.length, 1, "length should be 1");
|
||||
|
||||
ok(!replaceItemThrowsFor(strings, null),
|
||||
"SVGStringList.replaceItem() should not throw when passed null");
|
||||
ok(replaceItemThrowsFor(strings, ""),
|
||||
ok(replaceItemThrowsFor(strings, ""),
|
||||
"SVGStringList.replaceItem() should throw when passed the empty string");
|
||||
is(strings.length, 1, 'length should be 1');
|
||||
is(strings.length, 1, "length should be 1");
|
||||
|
||||
ok(!appendItemThrowsFor(strings, null),
|
||||
"SVGStringList.appendItem() should not throw when passed null");
|
||||
ok(appendItemThrowsFor(strings, ""),
|
||||
ok(appendItemThrowsFor(strings, ""),
|
||||
"SVGStringList.appendItem() should throw when passed the empty string");
|
||||
is(strings.length, 2, 'length should be 2');
|
||||
is(strings.length, 2, "length should be 2");
|
||||
|
||||
|
||||
// more sanity checks:
|
||||
|
|
@ -109,7 +104,7 @@ function run_tests()
|
|||
"SVGStringList.replaceItem() should not throw when passed a valid string");
|
||||
ok(!appendItemThrowsFor(strings, "valid-string"),
|
||||
"SVGStringList.appendItem() should not throw when passed a valid string");
|
||||
is(strings.length, 3, 'numberOfItems should be 3');
|
||||
is(strings.length, 3, "numberOfItems should be 3");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,8 @@ tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
|
|||
to other list types belongs there.
|
||||
*/
|
||||
|
||||
function main()
|
||||
{
|
||||
var g = $('g');
|
||||
function main() {
|
||||
var g = $("g");
|
||||
var tests =
|
||||
[ testConsolidateMatrix,
|
||||
testConsolidateMatrixOneElem,
|
||||
|
|
@ -42,7 +41,7 @@ function main()
|
|||
testReadOnly,
|
||||
testOrphan,
|
||||
testFailedSet,
|
||||
testMutationEvents
|
||||
testMutationEvents,
|
||||
];
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
tests[i](g);
|
||||
|
|
@ -50,8 +49,7 @@ function main()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testConsolidateMatrix(g)
|
||||
{
|
||||
function testConsolidateMatrix(g) {
|
||||
// This is the example from SVG 1.1 section 7.5
|
||||
g.setAttribute("transform",
|
||||
"translate(50 90) rotate(-45) translate(130 160)");
|
||||
|
|
@ -72,7 +70,7 @@ function testConsolidateMatrix(g)
|
|||
"Consolidate return value should be first item in list, not a copy");
|
||||
is(consolidated.type, SVGTransform.SVG_TRANSFORM_MATRIX,
|
||||
"Consolidated transform not of type matrix");
|
||||
const angle = -Math.PI/4;
|
||||
const angle = -Math.PI / 4;
|
||||
roughCmpMatrix(consolidated.matrix,
|
||||
[Math.cos(angle), Math.sin(angle),
|
||||
-Math.sin(angle), Math.cos(angle),
|
||||
|
|
@ -102,8 +100,7 @@ function testConsolidateMatrix(g)
|
|||
"Changing list doesn't affect return value from consolidate");
|
||||
}
|
||||
|
||||
function testConsolidateMatrixOneElem(g)
|
||||
{
|
||||
function testConsolidateMatrixOneElem(g) {
|
||||
// Check that even if we only have one item in the list it becomes a matrix
|
||||
// transform (as per the spec)
|
||||
g.setAttribute("transform", "translate(50 90)");
|
||||
|
|
@ -126,8 +123,7 @@ function testConsolidateMatrixOneElem(g)
|
|||
"Unexpected consolidated matrix value");
|
||||
}
|
||||
|
||||
function testConsolidateMatrixZeroElem(g)
|
||||
{
|
||||
function testConsolidateMatrixZeroElem(g) {
|
||||
// Check that zero items returns null
|
||||
g.setAttribute("transform", "");
|
||||
var list = g.transform.baseVal;
|
||||
|
|
@ -137,8 +133,7 @@ function testConsolidateMatrixZeroElem(g)
|
|||
"consolidate() should return null for a zero-length transform list");
|
||||
}
|
||||
|
||||
function testCreateSVGTransformFromMatrix(g)
|
||||
{
|
||||
function testCreateSVGTransformFromMatrix(g) {
|
||||
var m = createMatrix(1, 2, 3, 4, 5, 6);
|
||||
|
||||
// "Creates an SVGTransform object which is initialized to transform of type
|
||||
|
|
@ -169,34 +164,33 @@ function testCreateSVGTransformFromMatrix(g)
|
|||
var exception = null;
|
||||
try {
|
||||
t = list.createSVGTransformFromMatrix(null);
|
||||
} catch(e) { exception = e; }
|
||||
} catch (e) { exception = e; }
|
||||
ok(exception,
|
||||
"Failed to throw for null input to createSVGTransformFromMatrix");
|
||||
exception = null;
|
||||
try {
|
||||
t = list.createSVGTransformFromMatrix("undefined");
|
||||
} catch(e) { exception = e; }
|
||||
} catch (e) { exception = e; }
|
||||
ok(exception,
|
||||
"Failed to throw for string input to createSVGTransformFromMatrix");
|
||||
exception = null;
|
||||
try {
|
||||
t = list.createSVGTransformFromMatrix(SVGMatrix(t));
|
||||
} catch(e) { exception = e; }
|
||||
} catch (e) { exception = e; }
|
||||
ok(exception,
|
||||
"Failed to throw for bad input to createSVGTransformFromMatrix");
|
||||
exception = null;
|
||||
}
|
||||
|
||||
function testReadOnly(g)
|
||||
{
|
||||
var SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
function testReadOnly(g) {
|
||||
var SVG_NS = "http://www.w3.org/2000/svg";
|
||||
|
||||
// Just some data to work with
|
||||
g.setAttribute("transform", "translate(50 90)");
|
||||
|
||||
// baseVal / animVal are readonly attributes
|
||||
// Create another (empty) transform list
|
||||
var otherg = document.createElementNS(SVG_NS, 'g');
|
||||
var otherg = document.createElementNS(SVG_NS, "g");
|
||||
g.parentNode.appendChild(otherg);
|
||||
is(g.transform.baseVal.numberOfItems, 1,
|
||||
"Unexpected number of items in transform list before attempting to set");
|
||||
|
|
@ -255,7 +249,7 @@ function testReadOnly(g)
|
|||
threw = false;
|
||||
try {
|
||||
roTransform.setTranslate(2, 3);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "Failed to throw when calling setTranslate on read-only"
|
||||
|
|
@ -264,7 +258,7 @@ function testReadOnly(g)
|
|||
threw = false;
|
||||
try {
|
||||
roTransform.setScale(2, 3);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "Failed to throw when calling setScale on read-only transform");
|
||||
|
|
@ -272,7 +266,7 @@ function testReadOnly(g)
|
|||
threw = false;
|
||||
try {
|
||||
roTransform.setRotate(1, 2, 3);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "Failed to throw when calling setRotate on read-only transform");
|
||||
|
|
@ -280,7 +274,7 @@ function testReadOnly(g)
|
|||
threw = false;
|
||||
try {
|
||||
roTransform.setSkewX(2);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "Failed to throw when calling setSkewX on read-only transform");
|
||||
|
|
@ -288,7 +282,7 @@ function testReadOnly(g)
|
|||
threw = false;
|
||||
try {
|
||||
roTransform.setSkewY(2);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
ok(threw, "Failed to throw when calling setSkewY on read-only transform");
|
||||
|
|
@ -310,8 +304,7 @@ function testReadOnly(g)
|
|||
ok(threw, "Failed to throw exception when modifying read-only matrix");
|
||||
}
|
||||
|
||||
function testOrphan(g)
|
||||
{
|
||||
function testOrphan(g) {
|
||||
// Although this isn't defined, if a read-only object becomes orphaned
|
||||
// (detached from it's parent), then presumably it should become editable
|
||||
// again.
|
||||
|
|
@ -330,10 +323,10 @@ function testOrphan(g)
|
|||
var exception = null;
|
||||
try {
|
||||
roTransform.setTranslate(5, 3);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(exception===null,
|
||||
ok(exception === null,
|
||||
"Unexpected exception " + exception + " modifying orphaned transform");
|
||||
uexception = null;
|
||||
|
||||
|
|
@ -341,15 +334,14 @@ function testOrphan(g)
|
|||
exception = null;
|
||||
try {
|
||||
roMatrix.a = 1;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(exception===null,
|
||||
ok(exception === null,
|
||||
"Unexpected exception " + exception + " modifying orphaned matrix");
|
||||
}
|
||||
|
||||
function testFailedSet(g)
|
||||
{
|
||||
function testFailedSet(g) {
|
||||
// Check that a parse failure results in the attribute being empty
|
||||
|
||||
// Set initial value
|
||||
|
|
@ -365,8 +357,7 @@ function testFailedSet(g)
|
|||
"Animated transform list should also be empty after setting bad value");
|
||||
}
|
||||
|
||||
function testMutationEvents(g)
|
||||
{
|
||||
function testMutationEvents(g) {
|
||||
// Check mutation events
|
||||
|
||||
// Set initial value
|
||||
|
|
@ -390,7 +381,7 @@ function testMutationEvents(g)
|
|||
|
||||
// transform.setMatrix
|
||||
eventChecker.expect("modify");
|
||||
var mx = $('svg').createSVGMatrix();
|
||||
var mx = $("svg").createSVGMatrix();
|
||||
list[0].setMatrix(mx);
|
||||
list[0].setMatrix(mx);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,71 +28,68 @@ This file runs a series of tests specific to addition of SVGTransformList in
|
|||
animation.
|
||||
*/
|
||||
|
||||
function AdditionTestCase(desc, baseVal, animSpecs, expectedTransformList)
|
||||
{
|
||||
function AdditionTestCase(desc, baseVal, animSpecs, expectedTransformList) {
|
||||
this.desc = desc;
|
||||
this.baseVal = baseVal;
|
||||
this.animSpecs = animSpecs;
|
||||
this.expectedTransformList = expectedTransformList;
|
||||
}
|
||||
|
||||
function Transform(type, angle)
|
||||
{
|
||||
function Transform(type, angle) {
|
||||
this.type = type;
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
function main(g)
|
||||
{
|
||||
function main(g) {
|
||||
var cases = [
|
||||
new AdditionTestCase("Not additive",
|
||||
"translate(150 50)",
|
||||
{type: 'rotate', from: '0', to: '90'},
|
||||
{type: "rotate", from: "0", to: "90"},
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 90)]
|
||||
),
|
||||
new AdditionTestCase("To animation",
|
||||
"rotate(-90)",
|
||||
{type: 'rotate', to: '90'},
|
||||
{type: "rotate", to: "90"},
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 90)]
|
||||
),
|
||||
new AdditionTestCase("By animation",
|
||||
"rotate(-90)",
|
||||
{type: 'rotate', by: '180'},
|
||||
{type: "rotate", by: "180"},
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, -90),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 180)]
|
||||
),
|
||||
new AdditionTestCase("Normal additive: same type",
|
||||
"rotate(45)",
|
||||
{type: 'rotate', from: '0', to: '45', additive: 'sum'},
|
||||
{type: "rotate", from: "0", to: "45", additive: "sum"},
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 45),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 45)]
|
||||
),
|
||||
new AdditionTestCase("Normal additive: different type",
|
||||
"translate(50)",
|
||||
{type: 'rotate', from: '0', to: '90', additive: 'sum'},
|
||||
{type: "rotate", from: "0", to: "90", additive: "sum"},
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_TRANSLATE, 0),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 90)]
|
||||
),
|
||||
new AdditionTestCase("Stacked additive: same type",
|
||||
"rotate(-90)",
|
||||
[{type: 'rotate', from: '0', to: '90', additive: 'sum'},
|
||||
{type: 'rotate', from: '0', to: '90', additive: 'sum'}],
|
||||
[{type: "rotate", from: "0", to: "90", additive: "sum"},
|
||||
{type: "rotate", from: "0", to: "90", additive: "sum"}],
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, -90),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 90),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 90)]
|
||||
),
|
||||
new AdditionTestCase("Stacked additive: different types #1",
|
||||
"translate(50)",
|
||||
[{type: 'rotate', from: '0', to: '45', additive: 'sum'},
|
||||
{type: 'rotate', from: '0', to: '45', additive: 'sum'}],
|
||||
[{type: "rotate", from: "0", to: "45", additive: "sum"},
|
||||
{type: "rotate", from: "0", to: "45", additive: "sum"}],
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_TRANSLATE, 0),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 45),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 45)]
|
||||
),
|
||||
new AdditionTestCase("Stacked additive: different types #2",
|
||||
"skewX(20) translate(50)",
|
||||
[{type: 'rotate', from: '0', to: '45', additive: 'sum'},
|
||||
{type: 'rotate', from: '0', to: '45', additive: 'sum'}],
|
||||
[{type: "rotate", from: "0", to: "45", additive: "sum"},
|
||||
{type: "rotate", from: "0", to: "45", additive: "sum"}],
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_SKEWX, 20),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_TRANSLATE, 0),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 45),
|
||||
|
|
@ -100,10 +97,10 @@ function main(g)
|
|||
),
|
||||
new AdditionTestCase("Stacked additive: different types #3",
|
||||
"skewX(20) translate(50)",
|
||||
[{type: 'rotate', from: '0', to: '45', additive: 'sum'},
|
||||
{type: 'translate', from: '0', to: '30', additive: 'sum'},
|
||||
{type: 'translate', from: '0', to: '-30', additive: 'sum'},
|
||||
{type: 'rotate', from: '0', to: '45', additive: 'sum'}],
|
||||
[{type: "rotate", from: "0", to: "45", additive: "sum"},
|
||||
{type: "translate", from: "0", to: "30", additive: "sum"},
|
||||
{type: "translate", from: "0", to: "-30", additive: "sum"},
|
||||
{type: "rotate", from: "0", to: "45", additive: "sum"}],
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_SKEWX, 20),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_TRANSLATE, 0),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 45),
|
||||
|
|
@ -113,29 +110,28 @@ function main(g)
|
|||
),
|
||||
new AdditionTestCase("Base value with rotation around a centre",
|
||||
"rotate(90 50 50)",
|
||||
{type: 'translate', from: '0 0', to: '0 -50', additive: 'sum'},
|
||||
{type: "translate", from: "0 0", to: "0 -50", additive: "sum"},
|
||||
[new Transform(SVGTransform.SVG_TRANSFORM_ROTATE, 90),
|
||||
new Transform(SVGTransform.SVG_TRANSFORM_TRANSLATE, 0)]
|
||||
),
|
||||
];
|
||||
|
||||
for (var i = 0; i < cases.length; i++) {
|
||||
runAdditionTestCase(cases[i], $('g'), $('svg'));
|
||||
runAdditionTestCase(cases[i], $("g"), $("svg"));
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function runAdditionTestCase(test, elem, svg)
|
||||
{
|
||||
function runAdditionTestCase(test, elem, svg) {
|
||||
var anims = createAnims(test.animSpecs);
|
||||
|
||||
elem.setAttribute('transform', test.baseVal);
|
||||
elem.setAttribute("transform", test.baseVal);
|
||||
elem.appendChild(anims);
|
||||
|
||||
svg.setCurrentTime(1);
|
||||
var expected = test.expectedTransformList; // Array of Transform objects
|
||||
var actual = elem.transform.animVal; // SVGTransformList
|
||||
var actual = elem.transform.animVal; // SVGTransformList
|
||||
is(actual.numberOfItems, expected.length,
|
||||
"Unexpected number of transforms");
|
||||
|
||||
|
|
@ -143,7 +139,7 @@ function runAdditionTestCase(test, elem, svg)
|
|||
for (var i = 0; i < actual.numberOfItems; i++) {
|
||||
var transform = actual.getItem(i);
|
||||
var testDesc = " for transform " + i + " in '" + test.desc + "' test";
|
||||
is(transform.type, expected[i].type,
|
||||
is(transform.type, expected[i].type,
|
||||
"Unexpected transform type" + testDesc);
|
||||
is(transform.angle, expected[i].angle,
|
||||
"Unexpected transform angle" + testDesc);
|
||||
|
|
@ -156,8 +152,7 @@ function runAdditionTestCase(test, elem, svg)
|
|||
}
|
||||
}
|
||||
|
||||
function createAnims(specs)
|
||||
{
|
||||
function createAnims(specs) {
|
||||
if (specs.constructor == Array) {
|
||||
var frag = document.createDocumentFragment();
|
||||
for (var i = 0; i < specs.length; ++i) {
|
||||
|
|
@ -169,13 +164,12 @@ function createAnims(specs)
|
|||
return createAnim(specs);
|
||||
}
|
||||
|
||||
function createAnim(attrs)
|
||||
{
|
||||
var SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
var anim = document.createElementNS(SVG_NS, 'animateTransform');
|
||||
anim.setAttribute('attributeName', 'transform');
|
||||
anim.setAttribute('dur', '1s');
|
||||
anim.setAttribute('fill', 'freeze');
|
||||
function createAnim(attrs) {
|
||||
var SVG_NS = "http://www.w3.org/2000/svg";
|
||||
var anim = document.createElementNS(SVG_NS, "animateTransform");
|
||||
anim.setAttribute("attributeName", "transform");
|
||||
anim.setAttribute("dur", "1s");
|
||||
anim.setAttribute("fill", "freeze");
|
||||
for (attr in attrs) {
|
||||
anim.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=589640
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function debug(message) {
|
||||
document.getElementById('debug').appendChild(document.createTextNode(message + "\n"));
|
||||
document.getElementById("debug").appendChild(document.createTextNode(message + "\n"));
|
||||
}
|
||||
|
||||
function runTests()
|
||||
{
|
||||
var svg = document.getElementById('svg1');
|
||||
function runTests() {
|
||||
var svg = document.getElementById("svg1");
|
||||
for (var el = 0; el < svg.children.length; el++) {
|
||||
is(svg.children[el].id, svg.children[el].localName, svg.children[el].localName + " in the SVG namespace has a valid ID");
|
||||
debug(svg.children[el].localName + '.id = ' + svg.children[el].id);
|
||||
debug(svg.children[el].localName + ".id = " + svg.children[el].id);
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -22,8 +22,7 @@ var text = document.getElementById("text"),
|
|||
poly = document.getElementById("poly");
|
||||
g = document.getElementById("g");
|
||||
|
||||
function CheckList(aListObject, aExpectedListLength, aListDescription)
|
||||
{
|
||||
function CheckList(aListObject, aExpectedListLength, aListDescription) {
|
||||
is(aListObject.numberOfItems, aExpectedListLength, aListDescription + ".numberOfItems");
|
||||
is(aListObject.length, aExpectedListLength, aListDescription + ".length");
|
||||
for (let i = 0; i < aListObject.length; i++) {
|
||||
|
|
@ -69,7 +68,7 @@ var tests = [
|
|||
type: "SVGStringList",
|
||||
subtests: [ { values: null, length: 3 },
|
||||
{ values: "foo", length: 1 },
|
||||
{ values: "foo bar baz qux", length: 4 } ] }
|
||||
{ values: "foo bar baz qux", length: 4 } ] },
|
||||
];
|
||||
|
||||
for (let test of tests) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ function doNavigationTest(testNumber, initialHref, f) {
|
|||
if (f) {
|
||||
f(a);
|
||||
}
|
||||
sendMouseEvent({type:'click'}, a);
|
||||
sendMouseEvent({type: "click"}, a);
|
||||
}
|
||||
|
||||
window.onload = windowLoaded;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=508496
|
|||
/** Test object identity of animated lengths **/
|
||||
|
||||
/* Global Variables */
|
||||
const svgns="http://www.w3.org/2000/svg";
|
||||
const svgns = "http://www.w3.org/2000/svg";
|
||||
var svg = document.getElementById("svg");
|
||||
var circle = document.getElementById('circle');
|
||||
var circle = document.getElementById("circle");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ function main() {
|
|||
ok(animVal === circle.cx.animVal,
|
||||
"Got different animVal SVGLength objects at startup");
|
||||
|
||||
var animate = document.getElementById('animate');
|
||||
var animate = document.getElementById("animate");
|
||||
if (animate && animate.targetElement) {
|
||||
// Sample mid-way through the animation
|
||||
svg.setCurrentTime(5);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=506856
|
|||
/** Test read-only times of animated lengths **/
|
||||
|
||||
/* Global Variables */
|
||||
const svgns="http://www.w3.org/2000/svg";
|
||||
const svgns = "http://www.w3.org/2000/svg";
|
||||
var svg = document.getElementById("svg");
|
||||
var circle = document.getElementById('circle');
|
||||
var circle = document.getElementById("circle");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ function checkReadOnly(animLength) {
|
|||
// newValueSpecifiedUnits
|
||||
try {
|
||||
exceptionCaught = false;
|
||||
animLength.animVal.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX,-100);
|
||||
animLength.animVal.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, -100);
|
||||
} catch (e) { exceptionCaught = true; }
|
||||
ok(exceptionCaught, "animVal.newValueSpecifiedUnits failed to throw.");
|
||||
if (!exceptionCaught) return false;
|
||||
|
|
@ -139,8 +139,7 @@ function checkReadOnly(animLength) {
|
|||
return exceptionCaught;
|
||||
}
|
||||
|
||||
function checkSameValue(animLength)
|
||||
{
|
||||
function checkSameValue(animLength) {
|
||||
// value
|
||||
animLength.baseVal.value = 1;
|
||||
is(animLength.animVal.value, 1,
|
||||
|
|
@ -151,7 +150,7 @@ function checkSameValue(animLength)
|
|||
is(animLength.animVal.value, 2,
|
||||
"un-animated animVal.value not changed after setting "
|
||||
+ "baseValue.valueInSpecifiedUnits");
|
||||
|
||||
|
||||
// valueAsString
|
||||
animLength.baseVal.valueAsString = "3";
|
||||
is(animLength.animVal.value, 3,
|
||||
|
|
@ -171,8 +170,7 @@ function checkSameValue(animLength)
|
|||
+ "baseValue.convertToSpecifiedUnits");
|
||||
}
|
||||
|
||||
function checkDiffValue(animLength)
|
||||
{
|
||||
function checkDiffValue(animLength) {
|
||||
// We assume here that the animation is not additive and hence changing the
|
||||
// baseValue will not be reflected in the animValue
|
||||
var origValue = animLength.animVal.value;
|
||||
|
|
@ -187,7 +185,7 @@ function checkDiffValue(animLength)
|
|||
is(animLength.animVal.value, origValue,
|
||||
"animated animVal.value changed after setting "
|
||||
+ "baseValue.valueInSpecifiedUnits");
|
||||
|
||||
|
||||
// valueAsString
|
||||
animLength.baseVal.valueAsString = "3";
|
||||
is(animLength.animVal.value, origValue,
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=507067
|
|||
/** Test units of animated lengths **/
|
||||
|
||||
/* Global Variables */
|
||||
const svgns="http://www.w3.org/2000/svg";
|
||||
const svgns = "http://www.w3.org/2000/svg";
|
||||
var svg = document.getElementById("svg");
|
||||
var circle = document.getElementById('circle');
|
||||
var animate = document.getElementById('animate');
|
||||
var circle = document.getElementById("circle");
|
||||
var animate = document.getElementById("animate");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ function main() {
|
|||
"(1) Unexpected value for animVal during animation");
|
||||
|
||||
// Change font-size and check
|
||||
circle.parentNode.setAttribute('font-size', '5px');
|
||||
circle.parentNode.setAttribute("font-size", "5px");
|
||||
|
||||
// Currently, changing the font-size on a parent doesn't force a resample (see
|
||||
// bug 508206) so we have to give the animation a chance to run
|
||||
|
|
@ -93,7 +93,7 @@ function checkAfterChangeFontSize() {
|
|||
|
||||
// Do the same again, when the animation is frozen
|
||||
svg.setCurrentTime(10);
|
||||
circle.parentNode.setAttribute('font-size', '7px');
|
||||
circle.parentNode.setAttribute("font-size", "7px");
|
||||
|
||||
// Again, due to bug 508206 we need to give the animation a chance to resample
|
||||
window.requestAnimationFrame(checkWhilstFrozen);
|
||||
|
|
@ -112,7 +112,7 @@ function checkWhilstFrozen() {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
var animate = document.getElementById('animate');
|
||||
var animate = document.getElementById("animate");
|
||||
if (animate && animate.targetElement) {
|
||||
window.addEventListener("load", main);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -40,32 +40,31 @@ function checkBBox(id, options, x, y, width, height, msg) {
|
|||
is(bbox.height, height, id + ".getBBox().height" + msg);
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
// First call getBBox on 'rect1' with stroke included:
|
||||
$("rect1").setAttribute("stroke", "black");
|
||||
$("rect1").setAttribute("stroke-width", "10");
|
||||
checkBBox("rect1", { fill:true, stroke:true }, 5, 5, 20, 20, " with stroke");
|
||||
checkBBox("rect1", { fill: true, stroke: true }, 5, 5, 20, 20, " with stroke");
|
||||
|
||||
// Now remove the stroke from 'rect1' and check again:
|
||||
$("rect1").removeAttribute("stroke");
|
||||
$("rect1").removeAttribute("stroke-width");
|
||||
checkBBox("rect1", { fill:true }, 10, 10, 10, 10, " after stroke removed");
|
||||
checkBBox("rect1", { fill: true }, 10, 10, 10, 10, " after stroke removed");
|
||||
|
||||
// First call getBBox on 'rect2' without a stroke included:
|
||||
checkBBox("rect2", { fill:true }, 30, 10, 10, 10, " with stroke");
|
||||
checkBBox("rect2", { fill: true }, 30, 10, 10, 10, " with stroke");
|
||||
|
||||
// Now add a stroke to 'rect2' and check again:
|
||||
$("rect2").setAttribute("stroke", "black");
|
||||
$("rect2").setAttribute("stroke-width", "10");
|
||||
checkBBox("rect2", { fill:true, stroke:true }, 25, 5, 20, 20, " with stroke");
|
||||
checkBBox("rect2", { fill: true, stroke: true }, 25, 5, 20, 20, " with stroke");
|
||||
|
||||
// Check the initial result for getBBox on the group:
|
||||
checkBBox("g", { fill:true }, 55, 15, 70, 10, " before child moves");
|
||||
checkBBox("g", { fill: true }, 55, 15, 70, 10, " before child moves");
|
||||
|
||||
// Now move one of the circle children and check again:
|
||||
$("circle2").setAttribute("cx", "110");
|
||||
checkBBox("g", { fill:true }, 55, 15, 60, 10, " after child moves");
|
||||
checkBBox("g", { fill: true }, 55, 15, 60, 10, " after child moves");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=433063
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var bbox = $("svg").getBBox();
|
||||
is(bbox.x, 0, "Check bbox.x");
|
||||
is(bbox.y, 0, "Check bbox.y");
|
||||
|
|
@ -32,7 +31,7 @@ function run()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
window.addEventListener("load", run);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=449327
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var doc = $("svg").contentDocument;
|
||||
|
||||
function isFuzzy(a, b, error, name)
|
||||
{
|
||||
function isFuzzy(a, b, error, name) {
|
||||
ok(!(Math.abs(a - b) > error),
|
||||
name + " - got " + a + ", expected " + b + " (within " + error + ")");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,29 +30,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463934
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function Rect(left, top, width, height)
|
||||
{
|
||||
function Rect(left, top, width, height) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
Rect.prototype.roundOut = function()
|
||||
{
|
||||
Rect.prototype.roundOut = function() {
|
||||
this.width = Math.ceil(this.left + this.width) - Math.floor(this.left);
|
||||
this.height = Math.ceil(this.top + this.height) - Math.floor(this.top);
|
||||
this.left = Math.floor(this.left);
|
||||
this.top = Math.floor(this.top);
|
||||
}
|
||||
};
|
||||
|
||||
function isWithAbsTolerance(a, b, tolerance, message)
|
||||
{
|
||||
function isWithAbsTolerance(a, b, tolerance, message) {
|
||||
ok(tolerance >= Math.abs(a - b), message + " - got " + a + ", expected " + b + " ± " + tolerance);
|
||||
}
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var bounds;
|
||||
|
||||
bounds = document.getElementById("outer-1").getBoundingClientRect();
|
||||
|
|
@ -235,9 +231,9 @@ function runTest()
|
|||
|
||||
var nonScalingStrokedLine2Bounds =
|
||||
doc.getElementById("nonScalingStrokedLine2").getBoundingClientRect();
|
||||
var capDelta = 5/Math.SQRT2 + 5/Math.SQRT2;
|
||||
rect = new Rect(260 - capDelta, 15 - capDelta, 20/Math.SQRT2 + 2 * capDelta,
|
||||
20/Math.SQRT2 + 2 * capDelta);
|
||||
var capDelta = 5 / Math.SQRT2 + 5 / Math.SQRT2;
|
||||
rect = new Rect(260 - capDelta, 15 - capDelta, 20 / Math.SQRT2 + 2 * capDelta,
|
||||
20 / Math.SQRT2 + 2 * capDelta);
|
||||
isWithAbsTolerance(nonScalingStrokedLine2Bounds.left, rect.left, 0.1,
|
||||
"nonScalingStrokedLine2.getBoundingClientRect().left");
|
||||
isWithAbsTolerance(nonScalingStrokedLine2Bounds.top, rect.top, 0.1,
|
||||
|
|
@ -249,9 +245,9 @@ function runTest()
|
|||
|
||||
var nonScalingStrokedLine3Bounds =
|
||||
doc.getElementById("nonScalingStrokedLine3").getBoundingClientRect();
|
||||
var capDelta = 5/Math.SQRT2;
|
||||
rect = new Rect(280 - capDelta, 15 - capDelta, 20/Math.SQRT2 + 2 * capDelta,
|
||||
20/Math.SQRT2 + 2 * capDelta);
|
||||
var capDelta = 5 / Math.SQRT2;
|
||||
rect = new Rect(280 - capDelta, 15 - capDelta, 20 / Math.SQRT2 + 2 * capDelta,
|
||||
20 / Math.SQRT2 + 2 * capDelta);
|
||||
isWithAbsTolerance(nonScalingStrokedLine3Bounds.left, rect.left, 0.1,
|
||||
"nonScalingStrokedLine3.getBoundingClientRect().left");
|
||||
isWithAbsTolerance(nonScalingStrokedLine3Bounds.top, rect.top, 0.1,
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=872812
|
|||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript">
|
||||
|
||||
var svg = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
|
||||
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
ok(svg, "SVG exists");
|
||||
var a = document.createEvent('CustomEvent').initCustomEvent('', '', '', svg.viewBox);
|
||||
var a = document.createEvent("CustomEvent").initCustomEvent("", "", "", svg.viewBox);
|
||||
ok(true, "CustomEvent exists and we are not crashed!");
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=437448
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests()
|
||||
{
|
||||
function runTests() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
var filter = doc.getElementById("filter");
|
||||
var convolve = doc.getElementById("convolve");
|
||||
|
|
@ -253,7 +252,7 @@ function runTests()
|
|||
is(3, SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN, "SVG_PRESERVEASPECTRATIO_XMIDYMIN value");
|
||||
is(5, SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID, "SVG_PRESERVEASPECTRATIO_XMINYMID value");
|
||||
is(7, SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID, "SVG_PRESERVEASPECTRATIO_XMAXYMID value");
|
||||
is(10, SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX , "SVG_PRESERVEASPECTRATIO_XMAXYMAX value");
|
||||
is(10, SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX, "SVG_PRESERVEASPECTRATIO_XMAXYMAX value");
|
||||
|
||||
is(0, SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN, "SVG_MEETORSLICE_UNKNOWN value");
|
||||
is(1, SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET, "SVG_MEETORSLICE_MEET value");
|
||||
|
|
@ -272,7 +271,7 @@ function runTests()
|
|||
SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN;
|
||||
is(marker.preserveAspectRatio.animVal.align,
|
||||
SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN, "preserveAspectRatio animVal");
|
||||
is(marker.preserveAspectRatio.animVal.meetOrSlice,
|
||||
is(marker.preserveAspectRatio.animVal.meetOrSlice,
|
||||
SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE, "preserveAspectRatio.meetOrSlice animVal");
|
||||
marker.preserveAspectRatio.baseVal.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
|
||||
is(marker.preserveAspectRatio.animVal.align,
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=629200
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests()
|
||||
{
|
||||
function runTests() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
var filter = doc.getElementById("filter");
|
||||
var convolve = doc.getElementById("convolve");
|
||||
|
|
@ -32,7 +31,7 @@ function runTests()
|
|||
var eventChecker = new MutationEventChecker;
|
||||
|
||||
// class attribute
|
||||
|
||||
|
||||
eventChecker.watchAttr(filter, "class");
|
||||
eventChecker.expect("add modify remove add");
|
||||
filter.setAttribute("class", "foo");
|
||||
|
|
|
|||
|
|
@ -20,14 +20,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=759124
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function Test(svgFragmentIdentifier, valid, viewBoxString,
|
||||
preserveAspectRatioString, zoomAndPanString)
|
||||
{
|
||||
preserveAspectRatioString, zoomAndPanString) {
|
||||
this.svgFragmentIdentifier = svgFragmentIdentifier;
|
||||
this.valid = valid;
|
||||
}
|
||||
|
||||
function runTests()
|
||||
{
|
||||
function runTests() {
|
||||
var svg = $("svg");
|
||||
var doc = svg.contentWindow.document;
|
||||
var rootElement = doc.documentElement;
|
||||
|
|
@ -58,7 +56,7 @@ function runTests()
|
|||
new Test("svgView(zoomAndPan(disable)", false),
|
||||
new Test("svgView(zoomAndPan(disable) ", false),
|
||||
new Test("svgView(zoomAndPan(disable)]", false),
|
||||
new Test("svgView(zoomAndPan(disable)))", false)
|
||||
new Test("svgView(zoomAndPan(disable)))", false),
|
||||
];
|
||||
|
||||
var src = svg.getAttribute("src");
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=999964
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var flag = SpecialPowers.getBoolPref("svg.new-getBBox.enabled");
|
||||
if (!flag) {
|
||||
ok(!flag, "skip test for bug999964.");
|
||||
|
|
@ -34,8 +33,7 @@ function run()
|
|||
|
||||
var doc = $("svg").contentDocument;
|
||||
|
||||
function isFuzzy(a, b, error, name)
|
||||
{
|
||||
function isFuzzy(a, b, error, name) {
|
||||
ok(!(Math.abs(a - b) > error), name, "got " + a + ", expected " + b + " (within " + error + ")");
|
||||
}
|
||||
|
||||
|
|
@ -74,19 +72,19 @@ function run()
|
|||
// <text>
|
||||
// fill
|
||||
opt = { fill: true, stroke: false, markers: false, clipped: false };
|
||||
compareBBox1("text1","text3");
|
||||
compareBBox1("text2","text4");
|
||||
compareBBox1("text5","text6");
|
||||
compareBBox1("text1", "text3");
|
||||
compareBBox1("text2", "text4");
|
||||
compareBBox1("text5", "text6");
|
||||
// all
|
||||
opt = { fill: true, stroke: true, markers: true, clipped: true };
|
||||
compareBBox2("text1","text3");
|
||||
compareBBox2("text2","text4");
|
||||
compareBBox2("text5","text6");
|
||||
compareBBox2("text1", "text3");
|
||||
compareBBox2("text2", "text4");
|
||||
compareBBox2("text5", "text6");
|
||||
// clipped
|
||||
opt = { fill: false, stroke: false, markers: false, clipped: true };
|
||||
compareBBox2("text1","text3");
|
||||
compareBBox2("text2","text4");
|
||||
compareBBox2("text5","text6");
|
||||
compareBBox2("text1", "text3");
|
||||
compareBBox2("text2", "text4");
|
||||
compareBBox2("text5", "text6");
|
||||
|
||||
// <image>
|
||||
opt = { fill: true, stroke: true, markers: true, clipped: true };
|
||||
|
|
@ -106,138 +104,138 @@ function run()
|
|||
checkBBox("image14", opt, 0, 0, 0, 0);
|
||||
|
||||
opt = { fill: true, stroke: false, markers: false, clipped: false };
|
||||
checkBBox("image1", opt, 150,150,200,200, 0);
|
||||
checkBBox("image2", opt, 2,2,200,200, 0);
|
||||
checkBBox("image3", opt, 205,2,200,200, 0);
|
||||
checkBBox("image4", opt, 2,205,200,200, 0);
|
||||
checkBBox("image5", opt, 205,205,200,200, 0);
|
||||
checkBBox("image6", opt, 2,2,200,200, 0);
|
||||
checkBBox("image7", opt, 205,2,200,200, 0);
|
||||
checkBBox("image8", opt, 2,205,200,200, 0);
|
||||
checkBBox("image9", opt, 205,205,200,200, 0);
|
||||
checkBBox("image10", opt, 0,0,400,400, 0);
|
||||
checkBBox("image11", opt, 0,0,400,400, 0);
|
||||
checkBBox("image12", opt, 25,43,768,768, 0);
|
||||
checkBBox("image13", opt, 0,0,400,400, 0);
|
||||
checkBBox("image1", opt, 150, 150, 200, 200, 0);
|
||||
checkBBox("image2", opt, 2, 2, 200, 200, 0);
|
||||
checkBBox("image3", opt, 205, 2, 200, 200, 0);
|
||||
checkBBox("image4", opt, 2, 205, 200, 200, 0);
|
||||
checkBBox("image5", opt, 205, 205, 200, 200, 0);
|
||||
checkBBox("image6", opt, 2, 2, 200, 200, 0);
|
||||
checkBBox("image7", opt, 205, 2, 200, 200, 0);
|
||||
checkBBox("image8", opt, 2, 205, 200, 200, 0);
|
||||
checkBBox("image9", opt, 205, 205, 200, 200, 0);
|
||||
checkBBox("image10", opt, 0, 0, 400, 400, 0);
|
||||
checkBBox("image11", opt, 0, 0, 400, 400, 0);
|
||||
checkBBox("image12", opt, 25, 43, 768, 768, 0);
|
||||
checkBBox("image13", opt, 0, 0, 400, 400, 0);
|
||||
|
||||
// <path>
|
||||
opt = { fill: true, stroke: true, markers: true, clipped: true };
|
||||
checkBBox("path1", opt, 2,17,120,95, 0);
|
||||
checkBBox("path2", opt, 156,21,116,91, 0);
|
||||
checkBBox("path3", opt, 6,121,116,91, 0);
|
||||
checkBBox("path4", opt, 2,17,98,83, 0);
|
||||
checkBBox("path5", opt, 156,21,44,79, 0);
|
||||
checkBBox("path6", opt, 6,150,94,62, 0);
|
||||
checkBBox("path7", opt, 2,17,98,83, 0);
|
||||
checkBBox("path8", opt, 156,21,94,79, 0);
|
||||
checkBBox("path9", opt, 6,121,94,79, 0);
|
||||
checkBBox("path10", opt, 10,25,100,75, 0);
|
||||
checkBBox("path11", opt, 160,25,100,75, 0);
|
||||
checkBBox("path12", opt, 10,125,100,75, 0);
|
||||
checkBBox("path1", opt, 2, 17, 120, 95, 0);
|
||||
checkBBox("path2", opt, 156, 21, 116, 91, 0);
|
||||
checkBBox("path3", opt, 6, 121, 116, 91, 0);
|
||||
checkBBox("path4", opt, 2, 17, 98, 83, 0);
|
||||
checkBBox("path5", opt, 156, 21, 44, 79, 0);
|
||||
checkBBox("path6", opt, 6, 150, 94, 62, 0);
|
||||
checkBBox("path7", opt, 2, 17, 98, 83, 0);
|
||||
checkBBox("path8", opt, 156, 21, 94, 79, 0);
|
||||
checkBBox("path9", opt, 6, 121, 94, 79, 0);
|
||||
checkBBox("path10", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path11", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path12", opt, 10, 125, 100, 75, 0);
|
||||
|
||||
opt = { fill: true, stroke: false, markers: false, clipped: true };
|
||||
checkBBox("path1", opt, 10,25,100,75, 0);
|
||||
checkBBox("path2", opt, 160,25,100,75, 0);
|
||||
checkBBox("path3", opt, 10,125,100,75, 0);
|
||||
checkBBox("path4", opt, 10,25,90,75, 0);
|
||||
checkBBox("path5", opt, 160,25,40,75, 0);
|
||||
checkBBox("path6", opt, 10,150,90,50, 0);
|
||||
checkBBox("path7", opt, 10,25,90,75, 0);
|
||||
checkBBox("path8", opt, 160,25,90,75, 0);
|
||||
checkBBox("path9", opt, 10,125,90,75, 0);
|
||||
checkBBox("path10", opt, 10,25,100,75, 0);
|
||||
checkBBox("path11", opt, 160,25,100,75, 0);
|
||||
checkBBox("path12", opt, 10,125,100,75, 0);
|
||||
checkBBox("path1", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path2", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path3", opt, 10, 125, 100, 75, 0);
|
||||
checkBBox("path4", opt, 10, 25, 90, 75, 0);
|
||||
checkBBox("path5", opt, 160, 25, 40, 75, 0);
|
||||
checkBBox("path6", opt, 10, 150, 90, 50, 0);
|
||||
checkBBox("path7", opt, 10, 25, 90, 75, 0);
|
||||
checkBBox("path8", opt, 160, 25, 90, 75, 0);
|
||||
checkBBox("path9", opt, 10, 125, 90, 75, 0);
|
||||
checkBBox("path10", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path11", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path12", opt, 10, 125, 100, 75, 0);
|
||||
|
||||
opt = { fill: true, stroke: false, markers: false, clipped: false };
|
||||
checkBBox("path1", opt, 10,25,100,75, 0);
|
||||
checkBBox("path2", opt, 160,25,100,75, 0);
|
||||
checkBBox("path3", opt, 10,125,100,75, 0);
|
||||
checkBBox("path4", opt, 10,25,100,75, 0);
|
||||
checkBBox("path5", opt, 160,25,100,75, 0);
|
||||
checkBBox("path6", opt, 10,125,100,75, 0);
|
||||
checkBBox("path7", opt, 10,25,100,75, 0);
|
||||
checkBBox("path8", opt, 160,25,100,75, 0);
|
||||
checkBBox("path9", opt, 10,125,100,75, 0);
|
||||
checkBBox("path10", opt, 10,25,100,75, 0);
|
||||
checkBBox("path11", opt, 160,25,100,75, 0);
|
||||
checkBBox("path12", opt, 10,125,100,75, 0);
|
||||
checkBBox("path13", opt, 0,0,100,100, 0);
|
||||
checkBBox("path1", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path2", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path3", opt, 10, 125, 100, 75, 0);
|
||||
checkBBox("path4", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path5", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path6", opt, 10, 125, 100, 75, 0);
|
||||
checkBBox("path7", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path8", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path9", opt, 10, 125, 100, 75, 0);
|
||||
checkBBox("path10", opt, 10, 25, 100, 75, 0);
|
||||
checkBBox("path11", opt, 160, 25, 100, 75, 0);
|
||||
checkBBox("path12", opt, 10, 125, 100, 75, 0);
|
||||
checkBBox("path13", opt, 0, 0, 100, 100, 0);
|
||||
|
||||
opt = { fill: false, stroke: true, markers: false, clipped: false };
|
||||
checkBBox("path1", opt, 2,17,116,91, 0);
|
||||
checkBBox("path2", opt, 156,21,108,83, 0);
|
||||
checkBBox("path3", opt, 6,121,108,83, 0);
|
||||
checkBBox("path4", opt, 2,17,116,91, 0);
|
||||
checkBBox("path5", opt, 156,21,108,83, 0);
|
||||
checkBBox("path6", opt, 6,121,108,83, 0);
|
||||
checkBBox("path7", opt, 2,17,116,91, 0);
|
||||
checkBBox("path8", opt, 156,21,108,83, 0);
|
||||
checkBBox("path9", opt, 6,121,108,83, 0);
|
||||
checkBBox("path10", opt, 2,17,116,91, 0);
|
||||
checkBBox("path11", opt, 156,21,108,83, 0);
|
||||
checkBBox("path12", opt, 6,121,108,83, 0);
|
||||
checkBBox("path1", opt, 2, 17, 116, 91, 0);
|
||||
checkBBox("path2", opt, 156, 21, 108, 83, 0);
|
||||
checkBBox("path3", opt, 6, 121, 108, 83, 0);
|
||||
checkBBox("path4", opt, 2, 17, 116, 91, 0);
|
||||
checkBBox("path5", opt, 156, 21, 108, 83, 0);
|
||||
checkBBox("path6", opt, 6, 121, 108, 83, 0);
|
||||
checkBBox("path7", opt, 2, 17, 116, 91, 0);
|
||||
checkBBox("path8", opt, 156, 21, 108, 83, 0);
|
||||
checkBBox("path9", opt, 6, 121, 108, 83, 0);
|
||||
checkBBox("path10", opt, 2, 17, 116, 91, 0);
|
||||
checkBBox("path11", opt, 156, 21, 108, 83, 0);
|
||||
checkBBox("path12", opt, 6, 121, 108, 83, 0);
|
||||
|
||||
opt = { fill: false, stroke: false, markers: true, clipped: false };
|
||||
checkBBox("path1", opt, 10,25,112,87, 0);
|
||||
checkBBox("path2", opt, 160,25,112,87, 0);
|
||||
checkBBox("path3", opt, 10,125,112,87, 0);
|
||||
checkBBox("path4", opt, 10,25,112,87, 0);
|
||||
checkBBox("path5", opt, 160,25,112,87, 0);
|
||||
checkBBox("path6", opt, 10,125,112,87, 0);
|
||||
checkBBox("path7", opt, 10,25,112,87, 0);
|
||||
checkBBox("path8", opt, 160,25,112,87, 0);
|
||||
checkBBox("path9", opt, 10,125,112,87, 0);
|
||||
checkBBox("path10", opt, 10,25,112,87, 0);
|
||||
checkBBox("path11", opt, 160,25,112,87, 0);
|
||||
checkBBox("path12", opt, 10,125,112,87, 0);
|
||||
checkBBox("path1", opt, 10, 25, 112, 87, 0);
|
||||
checkBBox("path2", opt, 160, 25, 112, 87, 0);
|
||||
checkBBox("path3", opt, 10, 125, 112, 87, 0);
|
||||
checkBBox("path4", opt, 10, 25, 112, 87, 0);
|
||||
checkBBox("path5", opt, 160, 25, 112, 87, 0);
|
||||
checkBBox("path6", opt, 10, 125, 112, 87, 0);
|
||||
checkBBox("path7", opt, 10, 25, 112, 87, 0);
|
||||
checkBBox("path8", opt, 160, 25, 112, 87, 0);
|
||||
checkBBox("path9", opt, 10, 125, 112, 87, 0);
|
||||
checkBBox("path10", opt, 10, 25, 112, 87, 0);
|
||||
checkBBox("path11", opt, 160, 25, 112, 87, 0);
|
||||
checkBBox("path12", opt, 10, 125, 112, 87, 0);
|
||||
|
||||
// <use>
|
||||
opt = { fill: true, stroke: false, markers: false, clipped: false };
|
||||
checkBBox("use1", opt, 70,70,180,180, 0);
|
||||
checkBBox("use2", opt, 250,70,180,180, 0);
|
||||
checkBBox("use3", opt, 70,250,180,180, 0);
|
||||
checkBBox("use4", opt, 22,22,180,180, 0);
|
||||
checkBBox("use5", opt, 225,22,180,180, 0);
|
||||
checkBBox("use6", opt, 22,225,180,180, 0);
|
||||
checkBBox("use7", opt, 225,225,180,180, 0);
|
||||
checkBBox("use1", opt, 70, 70, 180, 180, 0);
|
||||
checkBBox("use2", opt, 250, 70, 180, 180, 0);
|
||||
checkBBox("use3", opt, 70, 250, 180, 180, 0);
|
||||
checkBBox("use4", opt, 22, 22, 180, 180, 0);
|
||||
checkBBox("use5", opt, 225, 22, 180, 180, 0);
|
||||
checkBBox("use6", opt, 22, 225, 180, 180, 0);
|
||||
checkBBox("use7", opt, 225, 225, 180, 180, 0);
|
||||
|
||||
opt = { fill: true, stroke: true, markers: true, clipped: true };
|
||||
checkBBox("use1", opt, 70,66,180,94, 0);
|
||||
checkBBox("use2", opt, 250,70,180,90, 0);
|
||||
checkBBox("use3", opt, 70,250,180,90, 0);
|
||||
checkBBox("use4", opt, 18,18,134,134, 0);
|
||||
checkBBox("use5", opt, 221,18,134,134, 0);
|
||||
checkBBox("use6", opt, 18,221,134,134, 0);
|
||||
checkBBox("use7", opt, 221,221,134,134, 0);
|
||||
checkBBox("use8", opt, 0,0,0,0, 0);
|
||||
checkBBox("use1", opt, 70, 66, 180, 94, 0);
|
||||
checkBBox("use2", opt, 250, 70, 180, 90, 0);
|
||||
checkBBox("use3", opt, 70, 250, 180, 90, 0);
|
||||
checkBBox("use4", opt, 18, 18, 134, 134, 0);
|
||||
checkBBox("use5", opt, 221, 18, 134, 134, 0);
|
||||
checkBBox("use6", opt, 18, 221, 134, 134, 0);
|
||||
checkBBox("use7", opt, 221, 221, 134, 134, 0);
|
||||
checkBBox("use8", opt, 0, 0, 0, 0, 0);
|
||||
|
||||
// <foreignObject>
|
||||
opt = { fill: true, stroke: false, markers: false, clipped: false };
|
||||
checkBBox("fo1", opt, 2,2,200,200, 0);
|
||||
checkBBox("fo2", opt, 205,2,200,200, 0);
|
||||
checkBBox("fo3", opt, 2,205,200,200, 0);
|
||||
checkBBox("fo4", opt, 205,205,200,200, 0);
|
||||
checkBBox("fo5", opt, 250,250,200,200, 0);
|
||||
checkBBox("fo6", opt, 0,0,200,200, 0);
|
||||
checkBBox("fo7", opt, 0,0,200,200, 0);
|
||||
checkBBox("fo1", opt, 2, 2, 200, 200, 0);
|
||||
checkBBox("fo2", opt, 205, 2, 200, 200, 0);
|
||||
checkBBox("fo3", opt, 2, 205, 200, 200, 0);
|
||||
checkBBox("fo4", opt, 205, 205, 200, 200, 0);
|
||||
checkBBox("fo5", opt, 250, 250, 200, 200, 0);
|
||||
checkBBox("fo6", opt, 0, 0, 200, 200, 0);
|
||||
checkBBox("fo7", opt, 0, 0, 200, 200, 0);
|
||||
|
||||
opt = { fill: true, stroke: true, markers: true, clipped: true };
|
||||
checkBBox("fo1", opt, 53,53,51,51, 0);
|
||||
checkBBox("fo2", opt, 205,53,148,149, 0);
|
||||
checkBBox("fo3", opt, 53,205,149,148, 0);
|
||||
checkBBox("fo4", opt, 207,207,100,100, 0);
|
||||
checkBBox("fo5", opt, 0,0,0,0, 0);
|
||||
checkBBox("fo6", opt, 100,100,100,100, 0);
|
||||
checkBBox("fo7", opt, 10,10,180,180, 0);
|
||||
checkBBox("fo8", opt, 0,0,0,0, 0);
|
||||
checkBBox("fo1", opt, 53, 53, 51, 51, 0);
|
||||
checkBBox("fo2", opt, 205, 53, 148, 149, 0);
|
||||
checkBBox("fo3", opt, 53, 205, 149, 148, 0);
|
||||
checkBBox("fo4", opt, 207, 207, 100, 100, 0);
|
||||
checkBBox("fo5", opt, 0, 0, 0, 0, 0);
|
||||
checkBBox("fo6", opt, 100, 100, 100, 100, 0);
|
||||
checkBBox("fo7", opt, 10, 10, 180, 180, 0);
|
||||
checkBBox("fo8", opt, 0, 0, 0, 0, 0);
|
||||
|
||||
// from http://www.w3.org/Graphics/SVG/Test/20110816/harness/htmlObjectApproved/masking-path-07-b.html
|
||||
opt = { fill: true, stroke: true, markers: true, clipped: true };
|
||||
checkBBox("rect-1", opt, 10,10,140,140, 0);
|
||||
checkBBox("rect-2", opt, 50,30,25,100, 0);
|
||||
checkBBox("rect-3", opt, 50,50,100,100, 0);
|
||||
checkBBox("g1", opt, 50,50,100,100, 0);
|
||||
checkBBox("rect-1", opt, 10, 10, 140, 140, 0);
|
||||
checkBBox("rect-2", opt, 50, 30, 25, 100, 0);
|
||||
checkBBox("rect-3", opt, 50, 50, 100, 100, 0);
|
||||
checkBBox("g1", opt, 50, 50, 100, 100, 0);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366697
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
|
||||
/* Minimal */
|
||||
|
|
@ -43,62 +42,62 @@ function runTest()
|
|||
/* Tests the consistency with nearestViewportElement
|
||||
(code is from test_viewport.html) */
|
||||
// root.nearestViewportElement == null
|
||||
is((function(){try{return root.getCTM()}catch(e){return e}})(), null, "root.getCTM()");
|
||||
is((function() { try { return root.getCTM(); } catch (e) { return e; } })(), null, "root.getCTM()");
|
||||
// inner.nearestViewportElement == root
|
||||
is((function(){try{return inner.getCTM().e}catch(e){return e}})(), 1, "inner.getCTM().e");
|
||||
is((function(){try{return inner.getCTM().f}catch(e){return e}})(), 2, "inner.getCTM().f");
|
||||
is((function() { try { return inner.getCTM().e; } catch (e) { return e; } })(), 1, "inner.getCTM().e");
|
||||
is((function() { try { return inner.getCTM().f; } catch (e) { return e; } })(), 2, "inner.getCTM().f");
|
||||
// g1.nearestViewportElement == inner
|
||||
is((function(){try{return g1.getCTM().e}catch(e){return e}})(), 30, "g1.getCTM().e");
|
||||
is((function(){try{return g1.getCTM().f}catch(e){return e}})(), 40, "g1.getCTM().f");
|
||||
is((function() { try { return g1.getCTM().e; } catch (e) { return e; } })(), 30, "g1.getCTM().e");
|
||||
is((function() { try { return g1.getCTM().f; } catch (e) { return e; } })(), 40, "g1.getCTM().f");
|
||||
// outer.nearestViewportElement == null
|
||||
is((function(){try{return outer.getCTM()}catch(e){return e}})(), null, "outer.getCTM()");
|
||||
is((function() { try { return outer.getCTM(); } catch (e) { return e; } })(), null, "outer.getCTM()");
|
||||
// g2.nearestViewportElement == outer
|
||||
is((function(){try{return g2.getCTM().e}catch(e){return e}})(), 600, "g2.getCTM().e");
|
||||
is((function(){try{return g2.getCTM().f}catch(e){return e}})(), 700, "g2.getCTM().f");
|
||||
is((function() { try { return g2.getCTM().e; } catch (e) { return e; } })(), 600, "g2.getCTM().e");
|
||||
is((function() { try { return g2.getCTM().f; } catch (e) { return e; } })(), 700, "g2.getCTM().f");
|
||||
// g3.nearestViewportElement == null
|
||||
is((function(){try{return g3.getCTM()}catch(e){return e}})(), null, "g3.getCTM()");
|
||||
is((function() { try { return g3.getCTM(); } catch (e) { return e; } })(), null, "g3.getCTM()");
|
||||
// g4.nearestViewportElement == null
|
||||
is((function(){try{return g4.getCTM().e}catch(e){return e}})(), 1, "g4.getCTM().e");
|
||||
is((function(){try{return g4.getCTM().f}catch(e){return e}})(), 2, "g4.getCTM().f");
|
||||
is((function() { try { return g4.getCTM().e; } catch (e) { return e; } })(), 1, "g4.getCTM().e");
|
||||
is((function() { try { return g4.getCTM().f; } catch (e) { return e; } })(), 2, "g4.getCTM().f");
|
||||
// symbolRect.nearestViewportElement == sym
|
||||
is((function(){try{return symbolRect.getCTM().e}catch(e){return e}})(), 70, "symbolRect.getCTM().e");
|
||||
is((function(){try{return symbolRect.getCTM().f}catch(e){return e}})(), 80, "symbolRect.getCTM().f");
|
||||
is((function() { try { return symbolRect.getCTM().e; } catch (e) { return e; } })(), 70, "symbolRect.getCTM().e");
|
||||
is((function() { try { return symbolRect.getCTM().f; } catch (e) { return e; } })(), 80, "symbolRect.getCTM().f");
|
||||
// fO.nearestViewportElement == <svg> with no 'id'
|
||||
is((function(){try{return fO.getCTM().e}catch(e){return e}})(), 2, "fO.getCTM().e");
|
||||
is((function(){try{return fO.getCTM().f}catch(e){return e}})(), 3, "fO.getCTM().f");
|
||||
// g5.nearestViewportElement == inner-2
|
||||
is((function(){try{return g5.getCTM()}catch(e){return e}})(), null, "g5.getCTM()");
|
||||
is((function() { try { return fO.getCTM().e; } catch (e) { return e; } })(), 2, "fO.getCTM().e");
|
||||
is((function() { try { return fO.getCTM().f; } catch (e) { return e; } })(), 3, "fO.getCTM().f");
|
||||
// g5.nearestViewportElement == inner-2
|
||||
is((function() { try { return g5.getCTM(); } catch (e) { return e; } })(), null, "g5.getCTM()");
|
||||
|
||||
/* Tests the consistency with farthestViewportElement
|
||||
(code is from test_viewport.html) */
|
||||
// root.farthestViewportElement == null (but actually == root)
|
||||
is((function(){try{return root.getScreenCTM().e}catch(e){return e}})(), 91.5, "root.getScreenCTM().e");
|
||||
is((function(){try{return root.getScreenCTM().f}catch(e){return e}})(), 33, "root.getScreenCTM().f");
|
||||
is((function() { try { return root.getScreenCTM().e; } catch (e) { return e; } })(), 91.5, "root.getScreenCTM().e");
|
||||
is((function() { try { return root.getScreenCTM().f; } catch (e) { return e; } })(), 33, "root.getScreenCTM().f");
|
||||
// inner.farthestViewportElement == root
|
||||
is((function(){try{return inner.getScreenCTM().e}catch(e){return e}})(), 97.5, "inner.getScreenCTM().e");
|
||||
is((function(){try{return inner.getScreenCTM().f}catch(e){return e}})(), 42, "inner.getScreenCTM().f");
|
||||
is((function() { try { return inner.getScreenCTM().e; } catch (e) { return e; } })(), 97.5, "inner.getScreenCTM().e");
|
||||
is((function() { try { return inner.getScreenCTM().f; } catch (e) { return e; } })(), 42, "inner.getScreenCTM().f");
|
||||
// g1.farthestViewportElement == root
|
||||
is((function(){try{return g1.getScreenCTM().e}catch(e){return e}})(), 142.5, "g1.getScreenCTM().e");
|
||||
is((function(){try{return g1.getScreenCTM().f}catch(e){return e}})(), 102, "g1.getScreenCTM().f");
|
||||
is((function() { try { return g1.getScreenCTM().e; } catch (e) { return e; } })(), 142.5, "g1.getScreenCTM().e");
|
||||
is((function() { try { return g1.getScreenCTM().f; } catch (e) { return e; } })(), 102, "g1.getScreenCTM().f");
|
||||
// outer.farthestViewportElement == null (but actually == root)
|
||||
is((function(){try{return outer.getScreenCTM().e}catch(e){return e}})(), 144, "outer.getScreenCTM().e");
|
||||
is((function(){try{return outer.getScreenCTM().f}catch(e){return e}})(), 103.5, "outer.getScreenCTM().f");
|
||||
is((function() { try { return outer.getScreenCTM().e; } catch (e) { return e; } })(), 144, "outer.getScreenCTM().e");
|
||||
is((function() { try { return outer.getScreenCTM().f; } catch (e) { return e; } })(), 103.5, "outer.getScreenCTM().f");
|
||||
// outer.farthestViewportElement == null (but actually == root)
|
||||
is((function(){try{return outer2.getScreenCTM().e}catch(e){return e}})(), -19, "outer2.getScreenCTM().e");
|
||||
is((function(){try{return outer2.getScreenCTM().f}catch(e){return e}})(), -8, "outer2.getScreenCTM().f");
|
||||
is((function() { try { return outer2.getScreenCTM().e; } catch (e) { return e; } })(), -19, "outer2.getScreenCTM().e");
|
||||
is((function() { try { return outer2.getScreenCTM().f; } catch (e) { return e; } })(), -8, "outer2.getScreenCTM().f");
|
||||
// g2.farthestViewportElement == outer (but actually == root)
|
||||
is((function(){try{return g2.getScreenCTM().e}catch(e){return e}})(), 1044, "g2.getScreenCTM().e");
|
||||
is((function(){try{return g2.getScreenCTM().f}catch(e){return e}})(), 1153.5, "g2.getScreenCTM().f");
|
||||
is((function() { try { return g2.getScreenCTM().e; } catch (e) { return e; } })(), 1044, "g2.getScreenCTM().e");
|
||||
is((function() { try { return g2.getScreenCTM().f; } catch (e) { return e; } })(), 1153.5, "g2.getScreenCTM().f");
|
||||
// g3.farthestViewportElement == null (but actually == null)
|
||||
is((function(){try{return g3.getScreenCTM()}catch(e){return e}})(), null, "g3.getScreenCTM()");
|
||||
is((function() { try { return g3.getScreenCTM(); } catch (e) { return e; } })(), null, "g3.getScreenCTM()");
|
||||
// symbolRect.farthestViewportElement == root
|
||||
is((function(){try{return symbolRect.getScreenCTM().e}catch(e){return e}})(), 202.5, "symbolRect.getScreenCTM().e");
|
||||
is((function(){try{return symbolRect.getScreenCTM().f}catch(e){return e}})(), 162, "symbolRect.getScreenCTM().f");
|
||||
is((function() { try { return symbolRect.getScreenCTM().e; } catch (e) { return e; } })(), 202.5, "symbolRect.getScreenCTM().e");
|
||||
is((function() { try { return symbolRect.getScreenCTM().f; } catch (e) { return e; } })(), 162, "symbolRect.getScreenCTM().f");
|
||||
// fO.farthestViewportElement == root
|
||||
is((function(){try{return fO.getScreenCTM().e}catch(e){return e}})(), 99, "symbolRect.getScreenCTM().e");
|
||||
is((function(){try{return fO.getScreenCTM().f}catch(e){return e}})(), 43.5, "symbolRect.getScreenCTM().f");
|
||||
is((function() { try { return fO.getScreenCTM().e; } catch (e) { return e; } })(), 99, "symbolRect.getScreenCTM().e");
|
||||
is((function() { try { return fO.getScreenCTM().f; } catch (e) { return e; } })(), 43.5, "symbolRect.getScreenCTM().f");
|
||||
// g5.farthestViewportElement == root
|
||||
is((function(){try{return g5.getScreenCTM()}catch(e){return e}})(), null, "g5.getScreenCTM()");
|
||||
is((function() { try { return g5.getScreenCTM(); } catch (e) { return e; } })(), null, "g5.getScreenCTM()");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function main()
|
||||
{
|
||||
function main() {
|
||||
var svgns = "http://www.w3.org/2000/svg";
|
||||
|
||||
var svg = document.getElementById("inner");
|
||||
|
|
|
|||
|
|
@ -19,21 +19,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420243
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests(text, charWidth)
|
||||
{
|
||||
function runTests(text, charWidth) {
|
||||
function chars(n) { return charWidth * n; }
|
||||
|
||||
function expectThrow(charnum, nchars)
|
||||
{
|
||||
try
|
||||
{
|
||||
function expectThrow(charnum, nchars) {
|
||||
try {
|
||||
text.getSubStringLength(charnum, nchars);
|
||||
ok(false,
|
||||
"text.getSubStringLength(" + charnum + "," + nchars + ") " +
|
||||
"should have thrown");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
is(e.name, "IndexSizeError",
|
||||
"expected an index error for " +
|
||||
"text.getSubStringLength(" + charnum + "," + nchars + ")");
|
||||
|
|
@ -42,17 +37,13 @@ function runTests(text, charWidth)
|
|||
"text.getSubStringLength(" + charnum + "," + nchars + ")");
|
||||
}
|
||||
}
|
||||
|
||||
function expectValue(charnum, nchars, expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
function expectValue(charnum, nchars, expected) {
|
||||
try {
|
||||
is(text.getSubStringLength(charnum, nchars), expected,
|
||||
"text.getSubStringLength(" + charnum + "," + nchars + ") " +
|
||||
"returned wrong value");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
ok(false,
|
||||
"unexpected exception for " +
|
||||
"text.getSubStringLength(" + charnum + "," + nchars + ")");
|
||||
|
|
@ -80,24 +71,20 @@ function runTests(text, charWidth)
|
|||
}
|
||||
|
||||
|
||||
function run()
|
||||
{
|
||||
try
|
||||
{
|
||||
function run() {
|
||||
try {
|
||||
var document = $("svg").contentWindow.document;
|
||||
var text = document.getElementById("text");
|
||||
|
||||
runTests(text, text.getSubStringLength(0, 1));
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
ok(false, "threw error: " + e);
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
window.addEventListener("load", run);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -22,20 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1474284
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function expectValue(id, expected)
|
||||
{
|
||||
function expectValue(id, expected) {
|
||||
isfuzzy(document.getElementById(id).getTotalLength(),
|
||||
expected, expected * 0.02,
|
||||
`getTotalLength() on element id="${id}" returned the wrong value`);
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
expectValue("path1", 55.19);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("load", run, false);
|
||||
window.addEventListener("load", run);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -19,43 +19,42 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1486952
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
const div = $('div');
|
||||
function run() {
|
||||
const div = $("div");
|
||||
const offsetX = div.offsetLeft;
|
||||
const offsetY = div.offsetTop;
|
||||
const outerRect = $('outerRect');
|
||||
const innerRect = $('innerRect');
|
||||
const outerSVG = $('outerSVG');
|
||||
const innerSVG = $('innerSVG');
|
||||
const outerRect = $("outerRect");
|
||||
const innerRect = $("innerRect");
|
||||
const outerSVG = $("outerSVG");
|
||||
const innerSVG = $("innerSVG");
|
||||
let got;
|
||||
|
||||
// Update the inner SVG viewBox to "move" the inner rectangle off its current
|
||||
// position on screen:
|
||||
innerSVG.setAttribute('viewBox', '-25 0 50 50');
|
||||
innerSVG.setAttribute("viewBox", "-25 0 50 50");
|
||||
got = document.elementFromPoint(offsetX + 150, offsetY + 25);
|
||||
is(got, innerRect, 'Should hit inner rectangle (1)');
|
||||
is(got, innerRect, "Should hit inner rectangle (1)");
|
||||
|
||||
// Update the inner SVG viewBox again. (At the time of writing, a reflow is
|
||||
// triggered the first time you change viewBox on an inner svg, so the
|
||||
// previous test is expected to always pass. This next test will fail if we're
|
||||
// updating overflows on the inner svg frame instead of its children).
|
||||
innerSVG.setAttribute('viewBox', '0 -25 50 50');
|
||||
innerSVG.setAttribute("viewBox", "0 -25 50 50");
|
||||
got = document.elementFromPoint(offsetX + 100, offsetY + 75);
|
||||
is(got, innerRect, 'Should hit inner rectangle (2)');
|
||||
is(got, innerRect, "Should hit inner rectangle (2)");
|
||||
|
||||
// Now update the outer SVG viewBox and confirm that both rectangles are
|
||||
// registered. (Note that in this case the overflow rectangle of the inner
|
||||
// svg is the inner svg's viewport, so be sure to "move" the outer svg so that
|
||||
// the "new" outer rectangle and inner svg are off the current outerRect
|
||||
// union inner svg viewport - hit testing still works in that union.)
|
||||
outerSVG.setAttribute('viewBox', '-200 0 400 100');
|
||||
outerSVG.setAttribute("viewBox", "-200 0 400 100");
|
||||
// Outer:
|
||||
got = document.elementFromPoint(offsetX + 250, offsetY + 50);
|
||||
is(got, outerRect, 'Should hit outer rectangle');
|
||||
is(got, outerRect, "Should hit outer rectangle");
|
||||
// Inner:
|
||||
got = document.elementFromPoint(offsetX + 300, offsetY + 75);
|
||||
is(got, innerRect, 'Should hit inner rectangle (3)');
|
||||
is(got, innerRect, "Should hit inner rectangle (3)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var elts = [
|
|||
document.getElementById("s0"),
|
||||
document.getElementById("s4"),
|
||||
document.getElementById("s12"),
|
||||
document.getElementById("s28")
|
||||
document.getElementById("s28"),
|
||||
];
|
||||
|
||||
function fs(idx) {
|
||||
|
|
@ -53,7 +53,7 @@ function fs(idx) {
|
|||
return getComputedStyle(elts[idx], "").wordSpacing;
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({'clear': [['font.minimum-size.zh-CN']]}, step1);
|
||||
SpecialPowers.pushPrefEnv({"clear": [["font.minimum-size.zh-CN"]]}, step1);
|
||||
|
||||
function step1() {
|
||||
is(fs(0), "0px", "at min font size 0, 0px should compute to 0px");
|
||||
|
|
@ -61,7 +61,7 @@ function step1() {
|
|||
is(fs(2), "12px", "at min font size 0, 12px should compute to 12px");
|
||||
is(fs(3), "28px", "at min font size 0, 28px should compute to 28px");
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['font.minimum-size.zh-CN', 7]]}, step2);
|
||||
SpecialPowers.pushPrefEnv({"set": [["font.minimum-size.zh-CN", 7]]}, step2);
|
||||
}
|
||||
|
||||
function step2() {
|
||||
|
|
@ -70,7 +70,7 @@ function step2() {
|
|||
is(fs(2), "12px", "at min font size 7, 12px should compute to 12px");
|
||||
is(fs(3), "28px", "at min font size 7, 28px should compute to 28px");
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['font.minimum-size.zh-CN', 18]]}, step3);
|
||||
SpecialPowers.pushPrefEnv({"set": [["font.minimum-size.zh-CN", 18]]}, step3);
|
||||
}
|
||||
|
||||
function step3() {
|
||||
|
|
@ -79,7 +79,7 @@ function step3() {
|
|||
is(fs(2), "18px", "at min font size 18, 12px should compute to 18px");
|
||||
is(fs(3), "28px", "at min font size 18, 28px should compute to 28px");
|
||||
|
||||
SpecialPowers.pushPrefEnv({'clear': [['font.minimum-size.zh-CN']]}, SimpleTest.finish);
|
||||
SpecialPowers.pushPrefEnv({"clear": [["font.minimum-size.zh-CN"]]}, SimpleTest.finish);
|
||||
}
|
||||
|
||||
//]]>
|
||||
|
|
|
|||
|
|
@ -24,19 +24,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=342513
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var svgDoc = document.getElementById('svg');
|
||||
var divElem = document.getElementById('div');
|
||||
function run() {
|
||||
var svgDoc = document.getElementById("svg");
|
||||
var divElem = document.getElementById("div");
|
||||
var expectedWidth = divElem.clientWidth;
|
||||
// test for the pixel width of the svg
|
||||
is(svgDoc.width.baseVal.value, expectedWidth, 'svgDoc.width.baseVal.value');
|
||||
is(svgDoc.width.baseVal.value, expectedWidth, "svgDoc.width.baseVal.value");
|
||||
|
||||
// set the SVG width to ~50% in pixels
|
||||
svgDoc.width.baseVal.newValueSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PX, Math.floor(expectedWidth/2));
|
||||
svgDoc.width.baseVal.newValueSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PX, Math.floor(expectedWidth / 2));
|
||||
svgDoc.width.baseVal.convertToSpecifiedUnits(svgDoc.width.baseVal.SVG_LENGTHTYPE_PERCENTAGE);
|
||||
// the valueInSpecifiedUnits should now be 50%
|
||||
is(Math.round(svgDoc.width.baseVal.valueInSpecifiedUnits), 50, 'valueInSpecifiedUnits after convertToSpecifiedUnits');
|
||||
is(Math.round(svgDoc.width.baseVal.valueInSpecifiedUnits), 50, "valueInSpecifiedUnits after convertToSpecifiedUnits");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function checkParseOk(spec, valueInUnits, units) {
|
|||
const tolerance = 1 / 65535;
|
||||
var actual = rect.x.baseVal.valueInSpecifiedUnits;
|
||||
ok(Math.abs(actual - valueInUnits) < tolerance,
|
||||
spec + ' (value) - got ' + actual + ', expected ' + valueInUnits);
|
||||
spec + " (value) - got " + actual + ", expected " + valueInUnits);
|
||||
|
||||
// Check unit part
|
||||
var unitMapping = {
|
||||
|
|
@ -65,7 +65,7 @@ function checkParseOk(spec, valueInUnits, units) {
|
|||
"mm": SVGLength.SVG_LENGTHTYPE_MM,
|
||||
"in": SVGLength.SVG_LENGTHTYPE_IN,
|
||||
"pt": SVGLength.SVG_LENGTHTYPE_PT,
|
||||
"pc": SVGLength.SVG_LENGTHTYPE_PC
|
||||
"pc": SVGLength.SVG_LENGTHTYPE_PC,
|
||||
};
|
||||
if (typeof units == "undefined") {
|
||||
units = "";
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=892372
|
|||
"orientAngle animVal after numeric angle is set");
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var m = $("m");
|
||||
|
||||
// Testing two conditions:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=829085
|
|||
function startTest() {
|
||||
SimpleTest.waitForFocus(function() {
|
||||
disableNonTestMouseEvents(true);
|
||||
var line = document.getElementById('line');
|
||||
var line = document.getElementById("line");
|
||||
// Send a click
|
||||
synthesizeMouseExpectEvent($("svg"), 170, 100, { },
|
||||
$("line"), "click",
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=589436
|
|||
|
||||
/* Global Variables */
|
||||
var svg = document.getElementById("svg");
|
||||
var script = document.getElementById('script');
|
||||
var mpath = document.getElementById('mpath');
|
||||
var animate = document.getElementById('animate');
|
||||
var script = document.getElementById("script");
|
||||
var mpath = document.getElementById("mpath");
|
||||
var animate = document.getElementById("animate");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1063073
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var object = document.querySelector("object");
|
||||
var cs = document.defaultView.getComputedStyle(object);
|
||||
var width = cs.getPropertyValue("width");
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500261
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
ok(true, 'onerror method called');
|
||||
function run() {
|
||||
ok(true, "onerror method called");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@ var gTypes = "zMmLlCcQqAaHhVvSsTt".split("");
|
|||
// order that they would appear in a path data string.
|
||||
var gArgumentNames = {
|
||||
Z: [],
|
||||
M: ['x', 'y'],
|
||||
L: ['x', 'y'],
|
||||
C: ['x1', 'y1', 'x2', 'y2', 'x', 'y'],
|
||||
Q: ['x1', 'y1', 'x', 'y'],
|
||||
A: ['r1', 'r2', 'angle', 'largeArcFlag', 'sweepFlag', 'x', 'y'],
|
||||
H: ['x'],
|
||||
V: ['y'],
|
||||
S: ['x2', 'y2', 'x', 'y'],
|
||||
T: ['x', 'y']
|
||||
M: ["x", "y"],
|
||||
L: ["x", "y"],
|
||||
C: ["x1", "y1", "x2", "y2", "x", "y"],
|
||||
Q: ["x1", "y1", "x", "y"],
|
||||
A: ["r1", "r2", "angle", "largeArcFlag", "sweepFlag", "x", "y"],
|
||||
H: ["x"],
|
||||
V: ["y"],
|
||||
S: ["x2", "y2", "x", "y"],
|
||||
T: ["x", "y"],
|
||||
};
|
||||
|
||||
// All of these prefixes leave the current point at 100,100. Some of them
|
||||
|
|
@ -79,7 +79,7 @@ var gPrefixes = [
|
|||
[3, "M50,50 C10,10,20,20,75,75 S75,75,100,100"],
|
||||
[3, "M50,50 C10,10,20,20,75,75 s0,0,25,25"],
|
||||
[3, "M50,50 c10,10,20,20,25,25 S75,75,100,100"],
|
||||
[3, "M50,50 c10,10,20,20,25,25 s0,0,25,25"]
|
||||
[3, "M50,50 c10,10,20,20,25,25 s0,0,25,25"],
|
||||
];
|
||||
|
||||
// These are all of the suffixes whose result is not dependent on whether the
|
||||
|
|
@ -120,7 +120,7 @@ var gPrefixes = [
|
|||
// convert the "M10,20" into its relative form, which is "m-90,-80" due to the
|
||||
// current point being 100,100. Half way through the animation between
|
||||
// "m-90,-80" and "m30,40" is thus "m-30,-20".
|
||||
//
|
||||
//
|
||||
// The expected result of the additive test is "m-120,-100". We take the
|
||||
// halfway value of the animation, "m-30,-20" and add it on to the underlying
|
||||
// value. Since the underlying value "M10,20" is an absolute moveto, we first
|
||||
|
|
@ -172,25 +172,23 @@ var gSuffixes = {
|
|||
hH: [[10], [20], [65], [175]],
|
||||
Vv: [[10], [20], [-35], [-125]],
|
||||
vV: [[10], [20], [65], [175]],
|
||||
Tt: [[10, 20], [30, 40], [-30,-20], [-120, -100]],
|
||||
Tt: [[10, 20], [30, 40], [-30, -20], [-120, -100]],
|
||||
tT: [[10, 20], [30, 40], [70, 80], [180, 200]],
|
||||
Ss: [[10, 20, 30, 40], [50, 60, 70, 80],
|
||||
[-20, -10, 0, 10], [-110, -90, -70, -50]],
|
||||
sS: [[10, 20, 30, 40], [50, 60, 70, 80],
|
||||
[80, 90, 100, 110], [190, 210, 230, 250]]
|
||||
[80, 90, 100, 110], [190, 210, 230, 250]],
|
||||
};
|
||||
|
||||
// Returns an array of property names that exist on an SVGPathSeg object
|
||||
// corresponding to the given segment type, in the order that they would
|
||||
// be present in a path data string.
|
||||
function argumentNames(aType)
|
||||
{
|
||||
function argumentNames(aType) {
|
||||
return gArgumentNames[aType.toUpperCase()];
|
||||
}
|
||||
|
||||
// Creates and returns a new element and sets some attributes on it.
|
||||
function newElement(aNamespaceURI, aLocalName, aAttributes)
|
||||
{
|
||||
function newElement(aNamespaceURI, aLocalName, aAttributes) {
|
||||
var e = document.createElementNS(aNamespaceURI, aLocalName);
|
||||
if (aAttributes) {
|
||||
for (let [name, value] of Object.entries(aAttributes)) {
|
||||
|
|
@ -201,8 +199,7 @@ function newElement(aNamespaceURI, aLocalName, aAttributes)
|
|||
}
|
||||
|
||||
// Creates and returns a new SVG element and sets some attributes on it.
|
||||
function newSVGElement(aLocalName, aAttributes)
|
||||
{
|
||||
function newSVGElement(aLocalName, aAttributes) {
|
||||
return newElement("http://www.w3.org/2000/svg", aLocalName, aAttributes);
|
||||
}
|
||||
|
||||
|
|
@ -218,8 +215,7 @@ function newSVGElement(aLocalName, aAttributes)
|
|||
// animation
|
||||
function addTest(aPrefixLength, aPrefix, aFromType, aFromArguments,
|
||||
aToType, aToArguments, aExpectedType, aExpectedArguments,
|
||||
aAdditive)
|
||||
{
|
||||
aAdditive) {
|
||||
var fromPath = aPrefix + aFromType + aFromArguments,
|
||||
toPath = aPrefix + aToType + aToArguments;
|
||||
|
||||
|
|
@ -245,8 +241,7 @@ function addTest(aPrefixLength, aPrefix, aFromType, aFromArguments,
|
|||
|
||||
// Generates an array of path segment arguments for the given type. aOffset
|
||||
// is a number to add on to all non-Boolean segment arguments.
|
||||
function generatePathSegmentArguments(aType, aOffset)
|
||||
{
|
||||
function generatePathSegmentArguments(aType, aOffset) {
|
||||
var args = new Array(argumentNames(aType).length);
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
args[i] = i * 10 + aOffset;
|
||||
|
|
@ -259,14 +254,12 @@ function generatePathSegmentArguments(aType, aOffset)
|
|||
}
|
||||
|
||||
// Returns whether interpolating between the two given types is valid.
|
||||
function isValidInterpolation(aFromType, aToType)
|
||||
{
|
||||
function isValidInterpolation(aFromType, aToType) {
|
||||
return aFromType.toUpperCase() == aToType.toUpperCase();
|
||||
}
|
||||
|
||||
// Runs the test.
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
for (let additive of [false, true]) {
|
||||
let indexOfExpectedArguments = additive ? 3 : 2;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=643419
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var p1 = document.getElementById("p1");
|
||||
var point = p1.getPointAtLength(200);
|
||||
is(point.x, 200);
|
||||
|
|
|
|||
|
|
@ -13,25 +13,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500174
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var svgDoc = document.getElementById('svg');
|
||||
function run() {
|
||||
var svgDoc = document.getElementById("svg");
|
||||
var div = document.getElementById("div");
|
||||
// Get the coords of the origin of the SVG canvas:
|
||||
var originX = div.offsetLeft;
|
||||
var originY = div.offsetTop;
|
||||
var circle = document.getElementById('circle');
|
||||
var path = document.getElementById('path');
|
||||
var circle = document.getElementById("circle");
|
||||
var path = document.getElementById("path");
|
||||
|
||||
var elementFromPoint = document.elementFromPoint(originX + 55, originY + 55);
|
||||
is(elementFromPoint, circle, 'Over circle stroke with pointer-events="all"');
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 205, originY + 55);
|
||||
is(elementFromPoint, circle, 'Over foreignObject, outside clip path');
|
||||
is(elementFromPoint, circle, "Over foreignObject, outside clip path");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 225, originY + 75);
|
||||
// XXX disabled. See See https://bugzilla.mozilla.org/show_bug.cgi?id=580983#c116
|
||||
//is(elementFromPoint, path, 'Over foreignObject, inside clip path');
|
||||
// is(elementFromPoint, path, 'Over foreignObject, inside clip path');
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=762679
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var svgDoc = document.getElementById("svg");
|
||||
var div = document.getElementById("div");
|
||||
// Get the coords of the origin of the SVG canvas:
|
||||
|
|
|
|||
|
|
@ -13,72 +13,71 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=820506
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var svgDoc = document.getElementById('svg');
|
||||
function run() {
|
||||
var svgDoc = document.getElementById("svg");
|
||||
var div = document.getElementById("div");
|
||||
// Get the coords of the origin of the SVG canvas:
|
||||
var originX = div.offsetLeft;
|
||||
var originY = div.offsetTop;
|
||||
var r1 = document.getElementById('r1');
|
||||
var r2 = document.getElementById('r2');
|
||||
var r1 = document.getElementById("r1");
|
||||
var r2 = document.getElementById("r2");
|
||||
var element;
|
||||
|
||||
// Test r1 just outsite the clip area:
|
||||
|
||||
element = document.elementFromPoint(originX + 19, originY + 19);
|
||||
is(element, background, 'Should not hit top-left of r1');
|
||||
is(element, background, "Should not hit top-left of r1");
|
||||
|
||||
element = document.elementFromPoint(originX + 101, originY + 19);
|
||||
is(element, background, 'Should not hit top-right of r1');
|
||||
is(element, background, "Should not hit top-right of r1");
|
||||
|
||||
element = document.elementFromPoint(originX + 101, originY + 101);
|
||||
is(element, background, 'Should not hit bottom-right of r1');
|
||||
is(element, background, "Should not hit bottom-right of r1");
|
||||
|
||||
element = document.elementFromPoint(originX + 19, originY + 101);
|
||||
is(element, background, 'Should not hit bottom-left of r1');
|
||||
is(element, background, "Should not hit bottom-left of r1");
|
||||
|
||||
// Test r1 just inside the clip area:
|
||||
|
||||
element = document.elementFromPoint(originX + 21, originY + 21);
|
||||
is(element, r1, 'Should hit top-left of r1');
|
||||
is(element, r1, "Should hit top-left of r1");
|
||||
|
||||
element = document.elementFromPoint(originX + 99, originY + 21);
|
||||
is(element, r1, 'Should hit top-right of r1');
|
||||
is(element, r1, "Should hit top-right of r1");
|
||||
|
||||
element = document.elementFromPoint(originX + 99, originY + 99);
|
||||
is(element, r1, 'Should hit bottom-right of r1');
|
||||
is(element, r1, "Should hit bottom-right of r1");
|
||||
|
||||
element = document.elementFromPoint(originX + 21, originY + 99);
|
||||
is(element, r1, 'Should hit bottom-left of r1');
|
||||
is(element, r1, "Should hit bottom-left of r1");
|
||||
|
||||
// Test r2 just outsite the clip area:
|
||||
|
||||
element = document.elementFromPoint(originX + 109, originY + 19);
|
||||
is(element, background, 'Should not hit top-left of r2');
|
||||
is(element, background, "Should not hit top-left of r2");
|
||||
|
||||
element = document.elementFromPoint(originX + 201, originY + 19);
|
||||
is(element, background, 'Should not hit top-right of r2');
|
||||
is(element, background, "Should not hit top-right of r2");
|
||||
|
||||
element = document.elementFromPoint(originX + 201, originY + 101);
|
||||
is(element, background, 'Should not hit bottom-right of r2');
|
||||
is(element, background, "Should not hit bottom-right of r2");
|
||||
|
||||
element = document.elementFromPoint(originX + 109, originY + 101);
|
||||
is(element, background, 'Should not hit bottom-left of r2');
|
||||
is(element, background, "Should not hit bottom-left of r2");
|
||||
|
||||
// Test r2 just inside the clip area:
|
||||
|
||||
element = document.elementFromPoint(originX + 121, originY + 21);
|
||||
is(element, r2, 'Should hit top-left of r2');
|
||||
is(element, r2, "Should hit top-left of r2");
|
||||
|
||||
element = document.elementFromPoint(originX + 199, originY + 21);
|
||||
is(element, r2, 'Should hit top-right of r2');
|
||||
is(element, r2, "Should hit top-right of r2");
|
||||
|
||||
element = document.elementFromPoint(originX + 199, originY + 99);
|
||||
is(element, r2, 'Should hit bottom-right of r2');
|
||||
is(element, r2, "Should hit bottom-right of r2");
|
||||
|
||||
element = document.elementFromPoint(originX + 121, originY + 99);
|
||||
is(element, r2, 'Should hit bottom-left of r2');
|
||||
is(element, r2, "Should hit bottom-left of r2");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,25 +13,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500174
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var svgDoc = document.getElementById('svg');
|
||||
function run() {
|
||||
var svgDoc = document.getElementById("svg");
|
||||
var div = document.getElementById("div");
|
||||
// Get the coords of the origin of the SVG canvas:
|
||||
var originX = div.offsetLeft;
|
||||
var originY = div.offsetTop;
|
||||
var circle = document.getElementById('circle');
|
||||
var path = document.getElementById('path');
|
||||
var circle = document.getElementById("circle");
|
||||
var path = document.getElementById("path");
|
||||
|
||||
var elementFromPoint = document.elementFromPoint(originX + 55, originY + 55);
|
||||
is(elementFromPoint, circle, 'Over circle stroke with pointer-events="all"');
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 205, originY + 55);
|
||||
is(elementFromPoint, circle, 'Over foreignObject, outside clip path');
|
||||
is(elementFromPoint, circle, "Over foreignObject, outside clip path");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 225, originY + 75);
|
||||
// XXX disabled. See See https://bugzilla.mozilla.org/show_bug.cgi?id=580983#c116
|
||||
//is(elementFromPoint, path, 'Over foreignObject, inside clip path');
|
||||
// is(elementFromPoint, path, 'Over foreignObject, inside clip path');
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500174
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var div = document.getElementById("div");
|
||||
// Get the coords of the origin of the SVG canvas:
|
||||
var originX = div.offsetLeft;
|
||||
|
|
@ -22,28 +21,28 @@ function run()
|
|||
var elementFromPoint;
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 18, originY + 30);
|
||||
isnot(elementFromPoint, div, 'Outside left edge of clipped area');
|
||||
isnot(elementFromPoint, div, "Outside left edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 22, originY + 30);
|
||||
is(elementFromPoint, div, 'Inside left edge of clipped area');
|
||||
is(elementFromPoint, div, "Inside left edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 30, originY + 18);
|
||||
isnot(elementFromPoint, div, 'Outside top edge of clipped area');
|
||||
isnot(elementFromPoint, div, "Outside top edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 30, originY + 22);
|
||||
is(elementFromPoint, div, 'Inside top edge of clipped area');
|
||||
is(elementFromPoint, div, "Inside top edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 42, originY + 30);
|
||||
isnot(elementFromPoint, div, 'Outside right edge of clipped area');
|
||||
isnot(elementFromPoint, div, "Outside right edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 38, originY + 30);
|
||||
is(elementFromPoint, div, 'Inside right edge of clipped area');
|
||||
is(elementFromPoint, div, "Inside right edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 30, originY + 42);
|
||||
isnot(elementFromPoint, div, 'Outside bottom edge of clipped area');
|
||||
isnot(elementFromPoint, div, "Outside bottom edge of clipped area");
|
||||
|
||||
elementFromPoint = document.elementFromPoint(originX + 30, originY + 38);
|
||||
is(elementFromPoint, div, 'Inside bottom edge of clipped area');
|
||||
is(elementFromPoint, div, "Inside bottom edge of clipped area");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,31 +13,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1119698
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var svgDoc = document.getElementById('svg');
|
||||
function run() {
|
||||
var svgDoc = document.getElementById("svg");
|
||||
var div = document.getElementById("div");
|
||||
// Get the coords of the origin of the SVG canvas:
|
||||
var originX = div.offsetLeft;
|
||||
var originY = div.offsetTop;
|
||||
var image4 = document.getElementById('image4');
|
||||
var image5 = document.getElementById('image5');
|
||||
var image4 = document.getElementById("image4");
|
||||
var image5 = document.getElementById("image5");
|
||||
var element;
|
||||
|
||||
element = document.elementFromPoint(originX + 20, originY + 20);
|
||||
is(element, background, 'Should not hit visibility:hidden image by default');
|
||||
is(element, background, "Should not hit visibility:hidden image by default");
|
||||
|
||||
element = document.elementFromPoint(originX + 120, originY + 20);
|
||||
is(element, background, 'Should not hit pointer-events:none image');
|
||||
is(element, background, "Should not hit pointer-events:none image");
|
||||
|
||||
element = document.elementFromPoint(originX + 220, originY + 20);
|
||||
is(element, background, 'Should not hit pointer-events:visible visibility:hidden image');
|
||||
is(element, background, "Should not hit pointer-events:visible visibility:hidden image");
|
||||
|
||||
element = document.elementFromPoint(originX + 320, originY + 20);
|
||||
is(element, image4, 'Should hit pointer-events:painted visibility:hidden image');
|
||||
is(element, image4, "Should hit pointer-events:painted visibility:hidden image");
|
||||
|
||||
element = document.elementFromPoint(originX + 420, originY + 20);
|
||||
is(element, image5, 'Should hit pointer-events:stroke visibility:hidden image');
|
||||
is(element, image5, "Should hit pointer-events:stroke visibility:hidden image");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=302971
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests()
|
||||
{
|
||||
function runTests() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
var rect = doc.getElementById("rect");
|
||||
var text = doc.getElementById("text");
|
||||
|
|
|
|||
|
|
@ -19,22 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=398825
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTests()
|
||||
{
|
||||
function runTests() {
|
||||
var document = $("svg").contentWindow.document;
|
||||
var text = document.getElementById("text");
|
||||
|
||||
function expectThrow(charnum, nchars)
|
||||
{
|
||||
try
|
||||
{
|
||||
function expectThrow(charnum, nchars) {
|
||||
try {
|
||||
text.selectSubString(charnum, nchars);
|
||||
ok(false,
|
||||
"text.selectSubString(" + charnum + "," + nchars + ") " +
|
||||
"should have thrown");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
is(e.name, "IndexSizeError",
|
||||
"expected an index error for " +
|
||||
"text.selectSubString(" + charnum + "," + nchars + ")");
|
||||
|
|
@ -44,23 +39,19 @@ function runTests()
|
|||
}
|
||||
}
|
||||
|
||||
function expectNoThrow(charnum, nchars, expected)
|
||||
{
|
||||
try
|
||||
{
|
||||
function expectNoThrow(charnum, nchars, expected) {
|
||||
try {
|
||||
text.selectSubString(charnum, nchars);
|
||||
ok(true,
|
||||
"text.selectSubString(" + charnum + "," + nchars + ") " +
|
||||
"should not have thrown");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
ok(false,
|
||||
"unexpected exception for " +
|
||||
"text.selectSubString(" + charnum + "," + nchars + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
expectThrow(100, 2);
|
||||
expectThrow(100, 0);
|
||||
expectThrow(3, 0);
|
||||
|
|
@ -76,7 +67,7 @@ function runTests()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
window.addEventListener("load", runTests, false);
|
||||
window.addEventListener("load", runTests);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -18,28 +18,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=676001
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var div = document.getElementById('div');
|
||||
var line = document.getElementById('line');
|
||||
var circle = document.getElementById('circle');
|
||||
function run() {
|
||||
var div = document.getElementById("div");
|
||||
var line = document.getElementById("line");
|
||||
var circle = document.getElementById("circle");
|
||||
var offsetX = div.offsetLeft;
|
||||
var offsetY = div.offsetTop;
|
||||
var got;
|
||||
|
||||
// line
|
||||
got = document.elementFromPoint(offsetX + 116, offsetY + 103);
|
||||
is(got, line, 'Should hit line (1)');
|
||||
is(got, line, "Should hit line (1)");
|
||||
|
||||
got = document.elementFromPoint(offsetX + 123, offsetY + 108);
|
||||
is(got, line, 'Should hit line (2)');
|
||||
is(got, line, "Should hit line (2)");
|
||||
|
||||
// circle
|
||||
got = document.elementFromPoint(offsetX + 188, offsetY + 158);
|
||||
is(got, circle, 'Should hit circle (1)');
|
||||
is(got, circle, "Should hit circle (1)");
|
||||
|
||||
got = document.elementFromPoint(offsetX + 185, offsetY + 162);
|
||||
is(got, circle, 'Should hit circle (2)');
|
||||
is(got, circle, "Should hit circle (2)");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,17 +13,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=589648
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var svg = document.getElementById('svg');
|
||||
function run() {
|
||||
var svg = document.getElementById("svg");
|
||||
var div = document.getElementById("div");
|
||||
var x = div.offsetLeft;
|
||||
var y = div.offsetTop;
|
||||
var got, expected;
|
||||
|
||||
got = document.elementFromPoint(5 + x, 5 + y);
|
||||
expected = document.getElementById('zero-length-square-caps');
|
||||
is(got, expected, 'Check hit on zero length subpath\'s square caps');
|
||||
expected = document.getElementById("zero-length-square-caps");
|
||||
is(got, expected, "Check hit on zero length subpath's square caps");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
var test = 1;
|
||||
|
||||
function checkBounds(element, x, y, w, h)
|
||||
{
|
||||
function checkBounds(element, x, y, w, h) {
|
||||
var bbox = element.getBBox();
|
||||
var name = element.nodeName;
|
||||
|
||||
|
|
@ -34,8 +33,7 @@ function checkBounds(element, x, y, w, h)
|
|||
++test;
|
||||
}
|
||||
|
||||
function checkWidth(element, w)
|
||||
{
|
||||
function checkWidth(element, w) {
|
||||
var bbox = element.getBBox();
|
||||
var name = element.nodeName;
|
||||
|
||||
|
|
@ -43,21 +41,19 @@ function checkWidth(element, w)
|
|||
++test;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
// Set accept_languages to something we know
|
||||
SpecialPowers.pushPrefEnv({"set": [["intl.accept_languages", "en-gb,en,it"]]}, run1);
|
||||
}
|
||||
|
||||
function run1()
|
||||
{
|
||||
function run1() {
|
||||
try {
|
||||
var doc = $("svg").contentDocument;
|
||||
var s = doc.getElementById("s");
|
||||
var first = doc.getElementById("first");
|
||||
var second = doc.getElementById("second");
|
||||
var third = doc.getElementById("third");
|
||||
|
||||
|
||||
first.setAttribute("systemLanguage", "fr");
|
||||
|
||||
/* test for an exact match */
|
||||
|
|
@ -75,7 +71,7 @@ function run1()
|
|||
/* test that we use the default if nothing matches */
|
||||
second.setAttribute("systemLanguage", "fr");
|
||||
checkWidth(s, 80);
|
||||
|
||||
|
||||
/* test we still ignore non-matches */
|
||||
second.removeAttribute("systemLanguage");
|
||||
third.setAttribute("systemLanguage", "fr");
|
||||
|
|
@ -89,7 +85,6 @@ function run1()
|
|||
first.setAttribute("systemLanguage", "en");
|
||||
second.setAttribute("systemLanguage", "en-gb");
|
||||
checkWidth(s, 50);
|
||||
|
||||
} finally {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,13 +31,12 @@
|
|||
<script class="testbody" type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function main()
|
||||
{
|
||||
var f = document.getElementById('f');
|
||||
var r = document.getElementById('r');
|
||||
var t = document.getElementById('t');
|
||||
var l1 = document.getElementById('l1');
|
||||
var l2 = document.getElementById('l2');
|
||||
function main() {
|
||||
var f = document.getElementById("f");
|
||||
var r = document.getElementById("r");
|
||||
var t = document.getElementById("t");
|
||||
var l1 = document.getElementById("l1");
|
||||
var l2 = document.getElementById("l2");
|
||||
const isMac = ("nsILocalFileMac" in SpecialPowers.Ci);
|
||||
|
||||
try {
|
||||
|
|
@ -89,7 +88,7 @@ function main()
|
|||
} else {
|
||||
is(document.activeElement.tabIndex, 5, "The active element tabindex is 5");
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
ok(false, "Got unexpected exception" + e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=392233
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
var text1 = doc.getElementById("text1");
|
||||
var text2 = doc.getElementById("text2");
|
||||
|
|
@ -29,19 +28,16 @@ function runTest()
|
|||
|
||||
var charWidth = text1.getSubStringLength(0, 1);
|
||||
|
||||
function isPoint(pt1, x, y, str)
|
||||
{
|
||||
function isPoint(pt1, x, y, str) {
|
||||
is(pt1.x, x, str + " x");
|
||||
is(pt1.y, y, str + " y");
|
||||
}
|
||||
|
||||
function ymost(r)
|
||||
{
|
||||
|
||||
function ymost(r) {
|
||||
return r.y + r.height;
|
||||
}
|
||||
|
||||
function xmost(r)
|
||||
{
|
||||
function xmost(r) {
|
||||
return r.x + r.width;
|
||||
}
|
||||
|
||||
|
|
@ -54,10 +50,10 @@ function runTest()
|
|||
is(text1.getComputedTextLength(), text1.getSubStringLength(0, 3), "text1 substring length");
|
||||
isPoint(text1.getStartPositionOfChar(0), 5, 25, "text1 char 0 start offset");
|
||||
isPoint(text1.getStartPositionOfChar(1), 5 + charWidth, 25, "text1 char 1 start offset");
|
||||
isPoint(text1.getStartPositionOfChar(2), 5 + 2*charWidth, 25, "text1 char 2 start offset");
|
||||
isPoint(text1.getStartPositionOfChar(2), 5 + 2 * charWidth, 25, "text1 char 2 start offset");
|
||||
isPoint(text1.getEndPositionOfChar(0), 5 + charWidth, 25, "text1 char 0 end offset");
|
||||
isPoint(text1.getEndPositionOfChar(1), 5 + 2*charWidth, 25, "text1 char 1 end offset");
|
||||
isPoint(text1.getEndPositionOfChar(2), 5 + 3*charWidth, 25, "text1 char 2 end offset");
|
||||
isPoint(text1.getEndPositionOfChar(1), 5 + 2 * charWidth, 25, "text1 char 1 end offset");
|
||||
isPoint(text1.getEndPositionOfChar(2), 5 + 3 * charWidth, 25, "text1 char 2 end offset");
|
||||
is(text1.getExtentOfChar(0).x, 5, "text1 char 0 extent x");
|
||||
is(text1.getExtentOfChar(0).width, text1.getSubStringLength(0, 1), "text1 char 0 extent width");
|
||||
ok(text1.getExtentOfChar(0).y < 25, "text1 char 0 extent y");
|
||||
|
|
@ -66,7 +62,7 @@ function runTest()
|
|||
is(text1.getExtentOfChar(1).width, text1.getSubStringLength(0, 1), "text1 char 1 extent width");
|
||||
is(text1.getExtentOfChar(1).y, text1.getExtentOfChar(0).y, "text1 char 0/1 extent y");
|
||||
is(text1.getExtentOfChar(1).height, text1.getExtentOfChar(0).height, "text1 char 0/1 extent height");
|
||||
is(text1.getExtentOfChar(2).x, 5 + 2*charWidth, "text1 char 2 extent x");
|
||||
is(text1.getExtentOfChar(2).x, 5 + 2 * charWidth, "text1 char 2 extent x");
|
||||
is(text1.getExtentOfChar(2).width, text1.getSubStringLength(0, 1), "text1 char 2 extent width");
|
||||
is(text1.getExtentOfChar(2).y, text1.getExtentOfChar(0).y, "text1 char 0/2 extent y");
|
||||
is(text1.getExtentOfChar(2).height, text1.getExtentOfChar(0).height, "text1 char 0/2 extent height");
|
||||
|
|
@ -85,13 +81,13 @@ function runTest()
|
|||
is(text1.getCharNumAtPosition(p), -1, "text1 finding no char on top");
|
||||
p.y = text1.getExtentOfChar(0).y + 0.1;
|
||||
is(text1.getCharNumAtPosition(p), 0, "text1 finding char 0 top edge");
|
||||
p.x = 5 + 3*charWidth - 0.1;
|
||||
p.x = 5 + 3 * charWidth - 0.1;
|
||||
is(text1.getCharNumAtPosition(p), 2, "text1 finding char 2 top edge");
|
||||
p.x = 5 + 3*charWidth + 0.1;
|
||||
p.x = 5 + 3 * charWidth + 0.1;
|
||||
is(text1.getCharNumAtPosition(p), -1, "text1 finding no char on right");
|
||||
|
||||
// Simple rotated-90 string ... width might change because of hinting
|
||||
|
||||
|
||||
charWidth = text2.getSubStringLength(0, 1);
|
||||
|
||||
is(text2.getNumberOfChars(), 3, "text2 length");
|
||||
|
|
@ -99,10 +95,10 @@ function runTest()
|
|||
is(text2.getComputedTextLength(), text2.getSubStringLength(0, 3), "text2 substring length");
|
||||
isPoint(text2.getStartPositionOfChar(0), 100, 125, "text2 char 0 start offset");
|
||||
isPoint(text2.getStartPositionOfChar(1), 100, 125 + charWidth, "text2 char 1 start offset");
|
||||
isPoint(text2.getStartPositionOfChar(2), 100, 125 + 2*charWidth, "text2 char 2 start offset");
|
||||
isPoint(text2.getStartPositionOfChar(2), 100, 125 + 2 * charWidth, "text2 char 2 start offset");
|
||||
isPoint(text2.getEndPositionOfChar(0), 100, 125 + charWidth, "text2 char 0 end offset");
|
||||
isPoint(text2.getEndPositionOfChar(1), 100, 125 + 2*charWidth, "text2 char 1 end offset");
|
||||
isPoint(text2.getEndPositionOfChar(2), 100, 125 + 3*charWidth, "text2 char 2 end offset");
|
||||
isPoint(text2.getEndPositionOfChar(1), 100, 125 + 2 * charWidth, "text2 char 1 end offset");
|
||||
isPoint(text2.getEndPositionOfChar(2), 100, 125 + 3 * charWidth, "text2 char 2 end offset");
|
||||
is(text2.getExtentOfChar(0).y, 125, "text2 char 0 extent y");
|
||||
isfuzzy(text2.getExtentOfChar(0).height, charWidth, 0.000001, "text2 char 0 extent height");
|
||||
ok(text2.getExtentOfChar(0).width < 100, "text2 char 0 extent x");
|
||||
|
|
@ -111,7 +107,7 @@ function runTest()
|
|||
isfuzzy(text2.getExtentOfChar(1).height, text2.getSubStringLength(0, 1), 0.000001, "text2 char 1 extent width");
|
||||
is(text2.getExtentOfChar(1).x, text2.getExtentOfChar(0).x, "text2 char 0/1 extent y");
|
||||
is(text2.getExtentOfChar(1).width, text2.getExtentOfChar(0).width, "text2 char 0/1 extent height");
|
||||
is(text2.getExtentOfChar(2).y, 125 + 2*charWidth, "text2 char 2 extent x");
|
||||
is(text2.getExtentOfChar(2).y, 125 + 2 * charWidth, "text2 char 2 extent x");
|
||||
isfuzzy(text2.getExtentOfChar(2).height, text2.getSubStringLength(0, 1), 0.000001, "text2 char 2 extent width");
|
||||
is(text2.getExtentOfChar(2).x, text2.getExtentOfChar(0).x, "text2 char 0/2 extent y");
|
||||
is(text2.getExtentOfChar(2).width, text2.getExtentOfChar(0).width, "text2 char 0/2 extent height");
|
||||
|
|
@ -130,19 +126,19 @@ function runTest()
|
|||
is(text2.getCharNumAtPosition(p), -1, "text2 finding no char on left");
|
||||
p.x = text2.getExtentOfChar(0).x + 0.1;
|
||||
is(text2.getCharNumAtPosition(p), 0, "text2 finding char 0 left edge");
|
||||
p.y = 125 + 3*charWidth - 0.1;
|
||||
p.y = 125 + 3 * charWidth - 0.1;
|
||||
is(text2.getCharNumAtPosition(p), 2, "text2 finding char 2 bottom edge");
|
||||
p.y = 1225 + 3*charWidth + 0.1;
|
||||
p.y = 1225 + 3 * charWidth + 0.1;
|
||||
is(text2.getCharNumAtPosition(p), -1, "text2 finding no char on bottom");
|
||||
|
||||
// Text along a thin rectangle path
|
||||
|
||||
|
||||
charWidth = text3.getSubStringLength(0, 1);
|
||||
|
||||
is(text3.getNumberOfChars(), 26, "text3 length");
|
||||
ok(text3.getComputedTextLength() > 0, "text3 measured length");
|
||||
is(text3.getComputedTextLength(), text3.getSubStringLength(0, 26), "text3 substring length");
|
||||
|
||||
|
||||
// character 12 should be on the bottom side
|
||||
is(text3.getStartPositionOfChar(12).y, 253, "text3 char 12 start offset");
|
||||
is(text3.getEndPositionOfChar(12).y, 253, "text3 char 12 end offset");
|
||||
|
|
@ -175,7 +171,7 @@ function runTests() {
|
|||
|
||||
var doc = $("svg").contentWindow.document;
|
||||
doc.getElementById("g").setAttribute("transform", "scale(2) rotate(90 200 200)");
|
||||
|
||||
|
||||
runTest();
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function runTest() {
|
|||
close(text.getExtentOfChar(i).width, width, "width of glyph " + i);
|
||||
checkCharNumAtPosition((start[i] + end[i]) / 2, 100, i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var w = extents[0].width;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=655877
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
var text1 = doc.getElementById("text1");
|
||||
var text2 = doc.getElementById("text2");
|
||||
|
|
@ -37,30 +36,25 @@ function runTest()
|
|||
|
||||
var epsilon = 0.001;
|
||||
|
||||
function isClose(a, b, str)
|
||||
{
|
||||
function isClose(a, b, str) {
|
||||
ok(Math.abs(a - b) < epsilon, str + " - " + b + " should be close to " + a);
|
||||
}
|
||||
|
||||
function isPoint(pt1, x, y, str)
|
||||
{
|
||||
function isPoint(pt1, x, y, str) {
|
||||
is(pt1.x, x, str + " x");
|
||||
is(pt1.y, y, str + " y");
|
||||
}
|
||||
|
||||
function isPointCloseX(pt1, x, y, str)
|
||||
{
|
||||
|
||||
function isPointCloseX(pt1, x, y, str) {
|
||||
isClose(pt1.x, x, str + " x");
|
||||
is(pt1.y, y, str + " y");
|
||||
}
|
||||
|
||||
function ymost(r)
|
||||
{
|
||||
function ymost(r) {
|
||||
return r.y + r.height;
|
||||
}
|
||||
|
||||
function xmost(r)
|
||||
{
|
||||
function xmost(r) {
|
||||
return r.x + r.width;
|
||||
}
|
||||
|
||||
|
|
@ -73,10 +67,10 @@ function runTest()
|
|||
is(text1.getComputedTextLength(), text1.getSubStringLength(0, 3), "text1 substring length");
|
||||
isPointCloseX(text1.getStartPositionOfChar(0), 10, 400, "text1 char 0 start offset");
|
||||
isPointCloseX(text1.getStartPositionOfChar(1), 10 + charWidth, 400, "text1 char 1 start offset");
|
||||
isPointCloseX(text1.getStartPositionOfChar(2), 10 + 2*charWidth, 400, "text1 char 2 start offset");
|
||||
isPointCloseX(text1.getStartPositionOfChar(2), 10 + 2 * charWidth, 400, "text1 char 2 start offset");
|
||||
isPointCloseX(text1.getEndPositionOfChar(0), 10 + charWidth, 400, "text1 char 0 end offset");
|
||||
isPointCloseX(text1.getEndPositionOfChar(1), 10 + 2*charWidth, 400, "text1 char 1 end offset");
|
||||
isPointCloseX(text1.getEndPositionOfChar(2), 10 + 3*charWidth, 400, "text1 char 2 end offset");
|
||||
isPointCloseX(text1.getEndPositionOfChar(1), 10 + 2 * charWidth, 400, "text1 char 1 end offset");
|
||||
isPointCloseX(text1.getEndPositionOfChar(2), 10 + 3 * charWidth, 400, "text1 char 2 end offset");
|
||||
is(text1.getExtentOfChar(0).x, 10, "text1 char 0 extent x");
|
||||
is(text1.getExtentOfChar(0).width, text1.getSubStringLength(0, 1), "text1 char 0 extent width");
|
||||
ok(text1.getExtentOfChar(0).y < 400, "text1 char 0 extent y");
|
||||
|
|
@ -85,7 +79,7 @@ function runTest()
|
|||
is(text1.getExtentOfChar(1).width, text1.getSubStringLength(0, 1), "text1 char 1 extent width");
|
||||
is(text1.getExtentOfChar(1).y, text1.getExtentOfChar(0).y, "text1 char 0/1 extent y");
|
||||
is(text1.getExtentOfChar(1).height, text1.getExtentOfChar(0).height, "text1 char 0/1 extent height");
|
||||
is(text1.getExtentOfChar(2).x, 10 + 2*charWidth, "text1 char 2 extent x");
|
||||
is(text1.getExtentOfChar(2).x, 10 + 2 * charWidth, "text1 char 2 extent x");
|
||||
is(text1.getExtentOfChar(2).width, text1.getSubStringLength(0, 1), "text1 char 2 extent width");
|
||||
is(text1.getExtentOfChar(2).y, text1.getExtentOfChar(0).y, "text1 char 0/2 extent y");
|
||||
is(text1.getExtentOfChar(2).height, text1.getExtentOfChar(0).height, "text1 char 0/2 extent height");
|
||||
|
|
@ -104,19 +98,19 @@ function runTest()
|
|||
is(text1.getCharNumAtPosition(p), -1, "text1 finding no char on top");
|
||||
p.y = text1.getExtentOfChar(0).y + 0.1;
|
||||
is(text1.getCharNumAtPosition(p), 0, "text1 finding char 0 top edge");
|
||||
p.x = 10 + 3*charWidth - 0.1;
|
||||
p.x = 10 + 3 * charWidth - 0.1;
|
||||
is(text1.getCharNumAtPosition(p), 2, "text1 finding char 2 top edge");
|
||||
p.x = 10 + 3*charWidth + 0.1;
|
||||
p.x = 10 + 3 * charWidth + 0.1;
|
||||
is(text1.getCharNumAtPosition(p), -1, "text1 finding no char on right");
|
||||
|
||||
// Text along a thin rectangle path
|
||||
|
||||
|
||||
charWidth = text2.getSubStringLength(0, 1);
|
||||
|
||||
is(text2.getNumberOfChars(), 26, "text2 length");
|
||||
ok(text2.getComputedTextLength() > 0, "text2 measured length");
|
||||
is(text2.getComputedTextLength(), text2.getSubStringLength(0, 26), "text2 substring length");
|
||||
|
||||
|
||||
// character 12 should be on the bottom side
|
||||
is(text2.getStartPositionOfChar(12).y, 860, "text2 char 12 start offset");
|
||||
isfuzzy(text2.getEndPositionOfChar(12).y, 860, 0.001, "text2 char 12 end offset");
|
||||
|
|
@ -137,7 +131,7 @@ function runTests() {
|
|||
|
||||
var doc = $("svg").contentWindow.document;
|
||||
doc.getElementById("g").setAttribute("transform", "rotate(90 200 200)");
|
||||
|
||||
|
||||
runTest();
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
var svg, doc, win, text, dragstart, dragend;
|
||||
|
||||
function drag(fromX, fromY, toX, toY, show)
|
||||
{
|
||||
function drag(fromX, fromY, toX, toY, show) {
|
||||
synthesizeMouse(doc.documentElement, fromX, fromY, { type: "mousemove" }, win);
|
||||
synthesizeMouse(doc.documentElement, fromX, fromY, { type: "mousedown" }, win);
|
||||
synthesizeMouse(doc.documentElement, toX, toY, { type: "mousemove" }, win);
|
||||
|
|
@ -40,27 +39,23 @@ function drag(fromX, fromY, toX, toY, show)
|
|||
}
|
||||
}
|
||||
|
||||
function click(x, y)
|
||||
{
|
||||
function click(x, y) {
|
||||
synthesizeMouse(doc.documentElement, x, y, { type: "mousemove" }, win);
|
||||
synthesizeMouse(doc.documentElement, x, y, { type: "mousedown" }, win);
|
||||
synthesizeMouse(doc.documentElement, x, y, { type: "mouseup" }, win);
|
||||
}
|
||||
|
||||
function selection_is(s, text)
|
||||
{
|
||||
function selection_is(s, text) {
|
||||
is(win.getSelection().toString(), s, text);
|
||||
}
|
||||
|
||||
function deselect()
|
||||
{
|
||||
function deselect() {
|
||||
// Click outside text (and outside all <rect> elements>) to deselect.
|
||||
click(15, 15);
|
||||
selection_is("", "deselecting by clicking outside text");
|
||||
}
|
||||
|
||||
function testSelection()
|
||||
{
|
||||
function testSelection() {
|
||||
svg = document.getElementsByTagName("iframe")[0];
|
||||
doc = svg.contentDocument;
|
||||
win = svg.contentWindow;
|
||||
|
|
@ -128,8 +123,7 @@ function testSelection()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
SimpleTest.executeSoon(testSelection);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=512636
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
function run() {
|
||||
var g, svg, t, m, m2;
|
||||
|
||||
svg = $('svg');
|
||||
g = $('g');
|
||||
svg = $("svg");
|
||||
g = $("g");
|
||||
|
||||
t = g.transform.baseVal.getItem(0);
|
||||
m = t.matrix;
|
||||
|
|
@ -61,7 +60,7 @@ function run()
|
|||
t.setMatrix(m2);
|
||||
|
||||
// check that setMatrix() took a copy of m
|
||||
ok(m != m2, 't.matrix identity');
|
||||
ok(m != m2, "t.matrix identity");
|
||||
|
||||
// test that the SVGTransform now reflects the matrix value
|
||||
checkTransform(t, SVGTransform.SVG_TRANSFORM_MATRIX,
|
||||
|
|
@ -80,9 +79,9 @@ function run()
|
|||
0, 1,
|
||||
0, 10,
|
||||
0, "matrix");
|
||||
|
||||
|
||||
// If ty is not supplied it is assumed to be zero
|
||||
g.setAttribute("transform", "translate(5)");
|
||||
g.setAttribute("transform", "translate(5)");
|
||||
|
||||
// test that the SVGTransform now reflects the matrix value
|
||||
checkTransform(t, SVGTransform.SVG_TRANSFORM_TRANSLATE,
|
||||
|
|
@ -96,8 +95,8 @@ function run()
|
|||
|
||||
// test that the SVGTransform now reflects the matrix value
|
||||
checkTransform(t, SVGTransform.SVG_TRANSFORM_ROTATE,
|
||||
Math.cos(Math.PI/2), Math.sin(Math.PI/2),
|
||||
-Math.sin(Math.PI/2), Math.cos(Math.PI/2),
|
||||
Math.cos(Math.PI / 2), Math.sin(Math.PI / 2),
|
||||
-Math.sin(Math.PI / 2), Math.cos(Math.PI / 2),
|
||||
0, 0,
|
||||
90, "rotate");
|
||||
|
||||
|
|
@ -107,7 +106,7 @@ function run()
|
|||
// test that the SVGTransform now reflects the matrix value
|
||||
checkTransform(t, SVGTransform.SVG_TRANSFORM_SKEWX,
|
||||
1, 0,
|
||||
Math.tan(Math.PI/4), Math.tan(Math.PI/4),
|
||||
Math.tan(Math.PI / 4), Math.tan(Math.PI / 4),
|
||||
0, 0,
|
||||
45, "skewX");
|
||||
|
||||
|
|
@ -116,7 +115,7 @@ function run()
|
|||
|
||||
// test that the SVGTransform now reflects the matrix value
|
||||
checkTransform(t, SVGTransform.SVG_TRANSFORM_SKEWY,
|
||||
Math.tan(Math.PI/4), Math.tan(Math.PI/4),
|
||||
Math.tan(Math.PI / 4), Math.tan(Math.PI / 4),
|
||||
0, 1,
|
||||
0, 0,
|
||||
45, "skewY");
|
||||
|
|
@ -145,9 +144,8 @@ function run()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testCreateTransform()
|
||||
{
|
||||
svg = $('svg');
|
||||
function testCreateTransform() {
|
||||
svg = $("svg");
|
||||
var t = svg.createSVGTransform();
|
||||
ok(t != svg.createSVGTransform(),
|
||||
"Got identical objects when creating new transform");
|
||||
|
|
@ -163,30 +161,28 @@ function testCreateTransform()
|
|||
m.f = 6;
|
||||
t = svg.createSVGTransformFromMatrix(m);
|
||||
ok(t.matrix != m,
|
||||
'createSVGTransformFromMatrix should copy matrix not adopt it');
|
||||
"createSVGTransformFromMatrix should copy matrix not adopt it");
|
||||
m.a = 7; // Just to be sure, changing m should not affect t
|
||||
checkTransform(t, SVGTransform.SVG_TRANSFORM_MATRIX,
|
||||
1, 2, 3, 4, 5, 6, 0, "createSVGTransformFromMatrix");
|
||||
}
|
||||
|
||||
function checkTransform(transform, type, a, b, c, d, e, f, angle, forWhat)
|
||||
{
|
||||
function checkTransform(transform, type, a, b, c, d, e, f, angle, forWhat) {
|
||||
var m = transform.matrix;
|
||||
is(transform.type, type, 'transform.type for ' + forWhat);
|
||||
roughlyEqual(m.a, a, 'matrix.a for ' + forWhat);
|
||||
roughlyEqual(m.b, b, 'matrix.b for ' + forWhat);
|
||||
roughlyEqual(m.c, c, 'matrix.c for ' + forWhat);
|
||||
roughlyEqual(m.d, d, 'matrix.d for ' + forWhat);
|
||||
roughlyEqual(m.e, e, 'matrix.e for ' + forWhat);
|
||||
roughlyEqual(m.f, f, 'matrix.f for ' + forWhat);
|
||||
is(transform.angle, angle, 'transform.angle for ' + forWhat);
|
||||
is(transform.type, type, "transform.type for " + forWhat);
|
||||
roughlyEqual(m.a, a, "matrix.a for " + forWhat);
|
||||
roughlyEqual(m.b, b, "matrix.b for " + forWhat);
|
||||
roughlyEqual(m.c, c, "matrix.c for " + forWhat);
|
||||
roughlyEqual(m.d, d, "matrix.d for " + forWhat);
|
||||
roughlyEqual(m.e, e, "matrix.e for " + forWhat);
|
||||
roughlyEqual(m.f, f, "matrix.f for " + forWhat);
|
||||
is(transform.angle, angle, "transform.angle for " + forWhat);
|
||||
}
|
||||
|
||||
function roughlyEqual(value, expected, msg)
|
||||
{
|
||||
function roughlyEqual(value, expected, msg) {
|
||||
const tolerance = 1 / 65535;
|
||||
ok(Math.abs(value - expected) < tolerance,
|
||||
msg + ' - got ' + value + ', expected ' + expected);
|
||||
msg + " - got " + value + ", expected " + expected);
|
||||
}
|
||||
|
||||
window.addEventListener("load", run);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ function checkParseOk(spec, expected) {
|
|||
return;
|
||||
|
||||
// Check each item
|
||||
for (var i=0; i < transformList.numberOfItems; i++) {
|
||||
for (var i = 0; i < transformList.numberOfItems; i++) {
|
||||
checkTransform(transformList.getItem(i), expected[i], spec, i);
|
||||
}
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ function checkTransform(transform, expected, spec, index) {
|
|||
"scale": SVGTransform.SVG_TRANSFORM_SCALE,
|
||||
"rotate": SVGTransform.SVG_TRANSFORM_ROTATE,
|
||||
"skewx": SVGTransform.SVG_TRANSFORM_SKEWX,
|
||||
"skewy": SVGTransform.SVG_TRANSFORM_SKEWY
|
||||
"skewy": SVGTransform.SVG_TRANSFORM_SKEWY,
|
||||
};
|
||||
var name = "Item " + index + " of '" + spec + "'";
|
||||
|
||||
|
|
@ -85,12 +85,12 @@ function checkTransform(transform, expected, spec, index) {
|
|||
}
|
||||
|
||||
// Compare matrix values (roughly)
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].forEach(function(item) {
|
||||
["a", "b", "c", "d", "e", "f"].forEach(function(item) {
|
||||
var actual = transform.matrix[item];
|
||||
var msg = name + " - matrix:" + item;
|
||||
const tolerance = 1 / 65535;
|
||||
ok(Math.abs(actual - expected[item]) < tolerance,
|
||||
msg + ' - got ' + actual + ', expected ' + expected[item]);
|
||||
msg + " - got " + actual + ", expected " + expected[item]);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1247733
|
|||
// use with 'await', to avoid onload callback hell.
|
||||
async function LoadIframeAsync(uri) {
|
||||
return new Promise(resolve => {
|
||||
iframe.addEventListener('load', resolve, {once: true});
|
||||
iframe.addEventListener("load", resolve, {once: true});
|
||||
// Kick off the requested load:
|
||||
iframe.src = uri;
|
||||
});
|
||||
|
|
@ -81,7 +81,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1247733
|
|||
|
||||
// Ensure reference snapshot looks different from blank snapshot:
|
||||
assertSnapshots(refSnapshot, blankSnapshot,
|
||||
false /*not equal*/, null /*no fuzz*/,
|
||||
false /* not equal*/, null /* no fuzz*/,
|
||||
"refSnapshot", "blankSnapshot");
|
||||
|
||||
// OK, assuming we've got a valid refSnapshot, we can now proceed to
|
||||
|
|
@ -94,7 +94,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1247733
|
|||
await LoadIframeAsync(secureURI);
|
||||
let secureSnapshot = snapshotWindow(iframeWin);
|
||||
assertSnapshots(secureSnapshot, refSnapshot,
|
||||
true /*equal*/, null /*no fuzz*/,
|
||||
true /* equal*/, null /* no fuzz*/,
|
||||
"secureSnapshot", "refSnapshot");
|
||||
|
||||
// Load insecure (HTTP) version of testcase (which should get
|
||||
|
|
@ -110,7 +110,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1247733
|
|||
// Capture snapshot of iframe showing upgraded-to-HTTPS version of testcase:
|
||||
let upgradedSnapshot = snapshotWindow(iframeWin);
|
||||
assertSnapshots(upgradedSnapshot, refSnapshot,
|
||||
true /*equal*/, null /*no fuzz*/,
|
||||
true /* equal*/, null /* no fuzz*/,
|
||||
"upgradedSnapshot", "refSnapshot");
|
||||
|
||||
// Check that the iframe did actually invoke our postMessage handler (which
|
||||
|
|
|
|||
|
|
@ -24,33 +24,32 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=539697
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function run()
|
||||
{
|
||||
var c = document.getElementById('c');
|
||||
var m = document.getElementById('m');
|
||||
function run() {
|
||||
var c = document.getElementById("c");
|
||||
var m = document.getElementById("m");
|
||||
|
||||
is(SVGLength.SVG_LENGTHTYPE_EMS, c.r.baseVal.unitType, 'unexpected units');
|
||||
c.r.baseVal.valueAsString = '2px';
|
||||
is(SVGLength.SVG_LENGTHTYPE_PX, c.r.baseVal.unitType, 'unexpected units');
|
||||
is(SVGLength.SVG_LENGTHTYPE_EMS, c.r.baseVal.unitType, "unexpected units");
|
||||
c.r.baseVal.valueAsString = "2px";
|
||||
is(SVGLength.SVG_LENGTHTYPE_PX, c.r.baseVal.unitType, "unexpected units");
|
||||
|
||||
try {
|
||||
c.r.baseVal.valueAsString = 'rubbish';
|
||||
ok(false, 'setting a length to rubbish should fail');
|
||||
c.r.baseVal.valueAsString = "rubbish";
|
||||
ok(false, "setting a length to rubbish should fail");
|
||||
} catch (e) {
|
||||
is(e.name, 'SyntaxError', 'syntax error expected');
|
||||
is(e.code, DOMException.SYNTAX_ERR, 'syntax error expected');
|
||||
is(e.name, "SyntaxError", "syntax error expected");
|
||||
is(e.code, DOMException.SYNTAX_ERR, "syntax error expected");
|
||||
}
|
||||
|
||||
is(SVGAngle.SVG_ANGLETYPE_RAD, m.orientAngle.baseVal.unitType, 'unexpected units');
|
||||
m.orientAngle.baseVal.valueAsString = '2grad';
|
||||
is(SVGAngle.SVG_ANGLETYPE_GRAD, m.orientAngle.baseVal.unitType, 'unexpected units');
|
||||
is(SVGAngle.SVG_ANGLETYPE_RAD, m.orientAngle.baseVal.unitType, "unexpected units");
|
||||
m.orientAngle.baseVal.valueAsString = "2grad";
|
||||
is(SVGAngle.SVG_ANGLETYPE_GRAD, m.orientAngle.baseVal.unitType, "unexpected units");
|
||||
|
||||
try {
|
||||
m.orientAngle.baseVal.valueAsString = 'rubbish';
|
||||
ok(false, 'setting an angle to rubbish should fail');
|
||||
m.orientAngle.baseVal.valueAsString = "rubbish";
|
||||
ok(false, "setting an angle to rubbish should fail");
|
||||
} catch (e) {
|
||||
is(e.name, 'SyntaxError', 'syntax error expected');
|
||||
is(e.code, DOMException.SYNTAX_ERR, 'syntax error expected');
|
||||
is(e.name, "SyntaxError", "syntax error expected");
|
||||
is(e.code, DOMException.SYNTAX_ERR, "syntax error expected");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
|
|
|
|||
|
|
@ -19,11 +19,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=467671
|
|||
|
||||
/** Test for Bug 467671 **/
|
||||
|
||||
function storeSVGPropertyAsExpando(localName, prop)
|
||||
{
|
||||
function storeSVGPropertyAsExpando(localName, prop) {
|
||||
var elem = document.createElementNS("http://www.w3.org/2000/svg", localName);
|
||||
|
||||
elem.addEventListener("click", function(){});
|
||||
elem.addEventListener("click", function() {});
|
||||
|
||||
var propVal = elem[prop];
|
||||
Object.prototype.toSource[prop + "_expando"] = propVal;
|
||||
|
|
@ -72,7 +71,7 @@ var elem2 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|||
elem1.appendChild(elem2);
|
||||
document.getElementById("content").appendChild(elem1);
|
||||
|
||||
elem2.addEventListener("click", function(){});
|
||||
elem2.addEventListener("click", function() {});
|
||||
|
||||
Object.prototype.toSource.expando = elem1;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1396642
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var testsElement = $("svg");
|
||||
|
||||
// Turn for instance `2.3` into `230` (px). Round to avoid floating point
|
||||
|
|
|
|||
|
|
@ -19,10 +19,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=483389
|
|||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest()
|
||||
{
|
||||
function runTest() {
|
||||
var doc = $("svg").contentWindow.document;
|
||||
|
||||
|
||||
var root = doc.documentElement;
|
||||
var inner = doc.getElementById("inner");
|
||||
var g1 = doc.getElementById("g1");
|
||||
|
|
@ -58,7 +57,7 @@ function runTest()
|
|||
is(g2.nearestViewportElement, outer, "g2.nearestViewportElement");
|
||||
is(g3.nearestViewportElement, null, "g3.nearestViewportElement");
|
||||
is(symbolRect.nearestViewportElement, sym, "symbolRect.nearestViewportElement");
|
||||
|
||||
|
||||
<!-- farthestViewportElement -->
|
||||
is(root.farthestViewportElement, null, "root.farthestViewportElement");
|
||||
is(inner.farthestViewportElement, root, "inner.farthestViewportElement");
|
||||
|
|
@ -67,7 +66,7 @@ function runTest()
|
|||
is(g2.farthestViewportElement, outer, "g2.farthestViewportElement");
|
||||
is(g3.farthestViewportElement, null, "g3.farthestViewportElement");
|
||||
is(symbolRect.farthestViewportElement, root, "symbolRect.farthestViewportElement");
|
||||
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue