Highlight

Showing posts with label bugs. Show all posts
Showing posts with label bugs. Show all posts

2014-09-10

How to freeze a Google Chrome tab

Chrome cares more about speed than user interaction. This simple bug just hung my tab while hogging one CPU core:
function isOverflowed(element){
    return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
}

function resize_to_fit(el){
 var size = parseFloat(el.style.fontSize) || 55
 log("resizing from " + size)
 while(isOverflowed(el) && size > 8){
  el.style.fontSize = size - 1
 }
}
Press Shift+Escape, sort by CPU descending, and end the offending process to recover. Still better than Firefox.

This is what i meant to write, to resize text content to fit an HTML element like a div:
function isOverflowed(element){
 return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth
}

function resizeToFit(el){
 var size = parseFloat(el.style.fontSize) || 55
 while(isOverflowed(el) && size > 8){
  size -= 1
  el.style.fontSize = size + "px"
 }
}

2013-10-03

IE8 is Evil.

>>var d = {1:"one", 2:"two",}
  "Expected identifier, string or number"
But that works in IE9's IE8 mode!

Fortunately IE10 does reproduce this bug; too bad IE9 won't upgrade on this Windows 7 machine due to DLL hell. Good thing i have remote desktops:
>>var d = {1:"one", 2:"two"}
undefined
>>d
{...}
That also works in IE8. Bug solved!

But wait, there's more! IE10's IE8 mode happily skips over
var approved_headcount = {
 "ICT": {201301: 1, 201302: 2, 2013.03: 3, 201304: 1, 201305: 2, 201306: 3},
 "Finance": {201301: 1, 201302: 2, 201303: 3, 201304: 1, 201305: 2, 201306: 3},
}
and is thus buggy at being buggy.

I guess they incinerated the IE8 parser as it also returns incorrect line numbers while parsing that code block.