Skip to content

Commit

Permalink
Fix flaky test failure in firefox where asking for bounding box of an…
Browse files Browse the repository at this point in the history
… svg element that has been detached from the dom produces NS_ERROR_FAILURE

Change: 120846455
dsmilkov authored and tensorflower-gardener committed Apr 26, 2016
1 parent 791a664 commit f037135
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -138,8 +138,17 @@ export class Minimap {
* was updated (e.g. when a node was expanded).
*/
update(): void {
// The origin hasn't rendered yet. Ignore making an update.
if (this.zoomG == null || this.zoomG.childElementCount === 0) {
let sceneSize = null;
try {
// Get the size of the entire scene.
sceneSize = this.zoomG.getBBox();
if (sceneSize.width === 0) {
// There is no scene anymore. We have been detached from the dom.
return;
}
} catch (e) {
// Firefox produced NS_ERROR_FAILURE if we have been
// detached from the dom.
return;
}
let $download = d3.select('#graphdownload');
@@ -182,8 +191,6 @@ export class Minimap {
let zoomTransform = $zoomG.attr('transform');
$zoomG.attr('transform', null);

// Get the size of the entire scene.
let sceneSize = this.zoomG.getBBox();
// Since we add padding, account for that here.
sceneSize.height += this.labelPadding * 2;
sceneSize.width += this.labelPadding * 2;
Original file line number Diff line number Diff line change
@@ -78,9 +78,16 @@ export let Class = {
*/
export function fit(svg, zoomG, d3zoom, callback) {
let svgRect = svg.getBoundingClientRect();
let sceneSize = zoomG.getBBox();
if (sceneSize.width === 0) {
// There is no scene anymore.
let sceneSize = null;
try {
sceneSize = zoomG.getBBox();
if (sceneSize.width === 0) {
// There is no scene anymore. We have been detached from the dom.
return;
}
} catch (e) {
// Firefox produced NS_ERROR_FAILURE if we have been
// detached from the dom.
return;
}
let scale = 0.9 * Math.min(

0 comments on commit f037135

Please sign in to comment.