What's up with document.domConfig on Firefox? - javascript

I was iterating over properties of document when I ran into an interesting phenomena in Firefox, document claims to support the property domConfig although MDC says it isn't implemented but when I try to retrieve the property I get an exception:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOM3Document.domConfig]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: javascript:alert(typeof(document.domConfig)) :: :: line 1" data: no]
The following shows the behaviour, both Chrome and IE are consistent (I haven't checked Opera) in saying that domConfig is not a property of window but Firefox claims it is but can't retrieve it (copy paste into URL field since I can't get markdown to give a link).
/* true in FF, false in other browsers */
javascript:alert("domConfig" in document)
/* exception in FF, 'undefined' in other browsers */
javascript:alert(typeof(document.domConfig))
What's going on here?

Pointy's right, domConfig is exposed in an interface (DOM Level 3 Core Document - in Mozilla's source it's called nsIDOM3Document), but is not implemented (see nsDocument::GetDomConfig()). typeof works by first getting the value, then determining its type (and not from the interface definition), so it's not surprising typeof document.domConfig throws an exception.
As for why it's been done this way, the bug this code was added in doesn't have any discussion about that, so we can only guess.
My guess is that for specifications Mozilla intended to implement it made sense to finalize ("freeze" in Mozilla's terms) the interfaces, so that they could be used from binary code without further modifications after new properties/methods of the interface got implemented. And it didn't seem to matter much one way or another.
If you're interested in hearing from the developers, you could ask in mozilla.dev.tech.dom or mozilla.dev.platform.

Related

JavascriptExecutor: Cannot read property 'removeAttribute' of null

I am using Javascript executor to remove readonly attribute but it is giving an error.
Cannot read property 'removeAttribute' of null.
I have seen different posts where people confirm that after removing AdBlock from Chrome it worked. I don't know what is AdBlock and how to remove it from Chrome Binary at runtime, so I tried Firefox (Gecko Driver) but it is also throwing the same error.
Code:
driver.get("http://jsfiddle.net/343Rb/");
runJS().executeScript("document.getElementById('myInput').removeAttribute('readonly')");
Browsers I tried:
Chrome Binary latest, Firefox (GeckoDriver latest) on Windows 7
Links I went through:
TypeError: Cannot read property "removeAttribute" of null
Cannot read property 'removeAttribute' of null: Cant find source of it
Cannot read property *0* of null
Few posts above are purely JS based so I believe is the reason they are not replying to me.
I am using Selenium 3.0, Windows 7, Firefox, Chrome, Java, Testng
The problem is that the element you want is inside an <iframe>. You need to switch to it before querying for your element:
driver.switchTo().frame('result');
Or:
driver.switchTo().frame(driver.findElement(By.name('result')));

"Function.prototype.toString called on incompatible object" on older versions of firefox

My website fails to load on older versions of Firefox.
The following is displayed in my console:
TypeError: Function.prototype.toString called on incompatible object.
I also see a warning that complains: mutating the [[Prototype]] of an object will cause your code to run very slowly, but this was a known issue with FF that didn't actually impact site responsiveness. So ignoring this warning for now.
The Function.prototype.toString error is my main focus, just because I want the site to actually show up for FF users. It seems like it's coming from a collection of babel-related node modules, including but not limited to: babel-core/browser-polyfill.min.js, babel-core/browser.min.js, babel-polyfill/browser.js, etc.
I depend on these libraries to transpile my ES6 react code, but haven't been able to find any fixes yet. Any insight into a workaround would be amazing.
Screenshot of console:
UPDATE 1
From what I could see in the console, the minified browser-polyfill.min.js complained about this line:
(Function.prototype,u,function(){return"function"==typeof this&&this[i]||c.call(this)})}
Specifically the ending, where it tries to attempt c.call(this).
Upon doing some digging it seems that this is the corresponding line in an unminfied version:
(Function.prototype, TO_STRING, function toString(){
return typeof this == 'function' && this[SRC] || $toString.call(this);
})
Still at a loss as to what exactly the issue is...

Object does not support this property or method IE8 error

I am running one application which is loading properly in all browsers except and keep getting "Object does not support this property or method" error. I am not sure which part to share here as i myself don't know which part is generating the error. Can anybody help me out with the area to look out for .

Permission denied for <file://> to get property XPCComponents.utils in Firefox

I want to use Reflect.parse in my JavaScript in Firefox.
MDN says to import this into the global object via
Components.utils.import("resource://gre/modules/reflect.jsm")
However, this results in the following error message:
Error: Permission denied for <file://> to get property XPCComponents.utils
I have tried this in Firefox 11 and Aurora.
How can I get access to Reflect.parse?
EDIT:
The error message is due to the following fragment:
Component.utils
There is no real solution to this problem. The documentation on Reflect.parse in the wiki is misleading, to say the least.
If you want a "pure" JavaScript solution in SpiderMonkey/Firefox, don't rely on Reflect.parse.
I see a lot of projects using the parser from Narcissus and I should have done the same.
EDIT: The Esprima project is an excellent implementation of the Mozilla Parser API. After replacing Reflect.parse with esprima.parse all my 150+ test cases were still green, except for 5 or so dealing with non-standard SpiderMonkey extensions like let expressions (which I find pretty impressive).

Google Chrome JavaScript error - cannot call method 'join' of null

I started to test my web site on google chrome and
'cannot call method 'join' of null'
appears when doing this:
var sChoices = oQuestion.aChoiceRand.join("");
In IE and FF works well. What I'm trying to do with this code is to join all the aChoiceRand array elements in a string without any separators. How can I solve this?
The problem's cause must be earlier, when oQuestion.aChoiceRand gets assigned: you think it's assigned to an array (and apparently IE and FF agree with you), Chrome is telling you that it's null instead. We can't really help without seeing the code that's supposed to assign oQuestion.aChoiceRand its value...

Categories