Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
fastviper
Posts: 46
Joined: Tue Mar 15, 2011 1:30 pm

Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by fastviper » Mon Apr 07, 2014 9:30 am

I get this error everytime I try to run iim in Firefox 28 (win/unix) on iMacros 8.8.x

Code: Select all

NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getCharPref] (Error code: -1001)
I found a solution I'd like to share. This is caused by lack of Byte Order Mark at the beginning of iim or csv file.

http://en.wikipedia.org/wiki/Byte_order_mark

It seems that it is treated as mandatory by either iMacros or Firefox. This is why opening and saving file in Notepad fixes the problem - these bytes are inserted.
One might use any tool to insert BOM bytes.

If generating imacros from python, use codecs module and insert codecs.BOM_UTF8:

Code: Select all

f = codecs.open(fpath, 'w', 'utf_8')
f.write(codecs.BOM_UTF8)
f.write(test_text.encode('utf_8'))
Anyway: BOM is *NOT* mandatory and someone should fix this (not sure if iMacros or Firefox is responsible).
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by chivracq » Mon Apr 07, 2014 1:17 pm

fastviper wrote:I get this error everytime I try to run iim in Firefox 28 (win/unix) on iMacros 8.8.x

Code: Select all

NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getCharPref] (Error code: -1001)
I found a solution I'd like to share. This is caused by lack of Byte Order Mark at the beginning of iim or csv file.

http://en.wikipedia.org/wiki/Byte_order_mark

It seems that it is treated as mandatory by either iMacros or Firefox. This is why opening and saving file in Notepad fixes the problem - these bytes are inserted.
One might use any tool to insert BOM bytes.

If generating imacros from python, use codecs module and insert codecs.BOM_UTF8:

Code: Select all

f = codecs.open(fpath, 'w', 'utf_8')
f.write(codecs.BOM_UTF8)
f.write(test_text.encode('utf_8'))
Anyway: BOM is *NOT* mandatory and someone should fix this (not sure if iMacros or Firefox is responsible).
Nice of you to share (by opening the 7th Thread now dedicated to the same Problem...!), only the Python part is new...

As I stated earlier in the 6th Thread, "In a Nutshell, Pb comes from FF28 and you just need to open once your .CSV File (on Win32/64) in Notepad (not in Excel) and to save it with UTF-8 Encoding (and on MacOS and Linux/Unix with UTF-8 with BOM)."

More Info in those 2 (main) Threads:
NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000
iMacros 8.6.0 Loop-Csv-2-Web.iim example not working

I had already replied to you (with the Solution and Explanation) in the 2nd Thread here above some 2 weeks ago but you never replied to my Question...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
fastviper
Posts: 46
Joined: Tue Mar 15, 2011 1:30 pm

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by fastviper » Mon Apr 07, 2014 2:23 pm

chivracq wrote: Nice of you to share (by opening the 7th Thread now dedicated to the same Problem...!), only the Python part is new...

As I stated earlier in the 6th Thread, "In a Nutshell, Pb comes from FF28 and you just need to open once your .CSV File (on Win32/64) in Notepad (not in Excel) and to save it with UTF-8 Encoding (and on MacOS and Linux/Unix with UTF-8 with BOM)."
Seventh thread, but first with non-manual solution and explanation.
The problem is in byte order mark code expected in every file iMacros in FF28 opens.

Adding that BOM code as the first characters in file solves the issue completly. You don't need manual steps if you generate your files from somewhere - this can be fixed with batch script or changing software.
Also, my test cases .iim files now reached more than 200 files - it's imposiible to manually resave them in notepad (even if I had Windows).
I have no hope of fast reaction for that problem as previous experience shows (months of waiting) :)
chivracq
Posts: 9430
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by chivracq » Tue Apr 08, 2014 12:29 am

fastviper wrote:
chivracq wrote: Nice of you to share (by opening the 7th Thread now dedicated to the same Problem...!), only the Python part is new...

As I stated earlier in the 6th Thread, "In a Nutshell, Pb comes from FF28 and you just need to open once your .CSV File (on Win32/64) in Notepad (not in Excel) and to save it with UTF-8 Encoding (and on MacOS and Linux/Unix with UTF-8 with BOM)."
Seventh thread, but first with non-manual solution and explanation.
The problem is in byte order mark code expected in every file iMacros in FF28 opens.

Adding that BOM code as the first characters in file solves the issue completly. You don't need manual steps if you generate your files from somewhere - this can be fixed with batch script or changing software.
Also, my test cases .iim files now reached more than 200 files - it's imposiible to manually resave them in notepad (even if I had Windows).
I have no hope of fast reaction for that problem as previous experience shows (months of waiting) :)
Moaw..., we had the same "Explanation" already 2 months ago in the original Thread where you briefly jumped into... but your Python Script can be a great Contribution, though I don't see (yet) exactly how to concretely use it in a Batch, but I don't know anything about Python myself, so I would need to dig/dive into it...

In my Opinion, the Problem comes from Firefox (from v28) and not from iMacros as the Error Msg is a Firefox Error Msg and iMacros (for FF) v8.60 already had the Pb with FF28 + FF29 (no Pb until FF27) and iMacros v.8.8.1 has the Pb with FF28 + FF29 + FF30 (no Pb until FF27), and Pale Moon (forked Firefox) v24.3.4 (=FF27) + v24.4.1 and v24.4.2 (=FF28) do not experience the Pb at all...

Though, as the Pb has been known for 2 months already, so long before iMacros v8.8.1 was released, they (the iMacros Developers) could have built a Mechanism to catch that Error with their own Error Msg offering to (re-)save the DataSource in UTF-8 with BOM Encoding or at least explaining to do so... And the iMacros TechSupport never reacted on the Forum about the Problem...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Tom, Tech Support
Posts: 3609
Joined: Mon May 31, 2010 4:59 pm

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by Tom, Tech Support » Wed Apr 16, 2014 8:49 am

A new beta version of iMacros for Firefox is available that fixes the issue with ANSI files that was introduced in Firefox 28.

You can download the .xpi from the following location:

http://wiki.imacros.net/iMacros_for_Fir ... on_History
Regards,

Tom, iMacros Support
divaker
Posts: 4
Joined: Wed May 07, 2014 11:25 am

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by divaker » Wed May 07, 2014 11:53 am

i got the same error with new firefox version but when i install my older firefox version it worked
rs904c
Posts: 5
Joined: Tue Apr 14, 2015 1:41 am

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by rs904c » Tue Apr 14, 2015 1:48 am

I still get the "byte order mark" at the beginning of the file with this new beta version.
So, this version does NOT appear to fix the problem.

Details:
Using method: SAVEAS TYPE=EXTRACT FOLDER=...
Firefox Portable v30.0
iMacros for Firefox v8.9.2 beta 2 (downloaded from the link provided above)

Please help.
Tom, Tech Support
Posts: 3609
Joined: Mon May 31, 2010 4:59 pm

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by Tom, Tech Support » Thu Apr 16, 2015 9:13 am

Hi rs904c,
rs904c wrote:I still get the "byte order mark" at the beginning of the file with this new beta version.
So, this version does NOT appear to fix the problem.

Details:
Using method: SAVEAS TYPE=EXTRACT FOLDER=...
Firefox Portable v30.0
iMacros for Firefox v8.9.2 beta 2 (downloaded from the link provided above)

Please help.
This is a different issue than what is covered in this thread. This thread dealt with the issue of iMacros for Firefox not being able to read ANSI files after a particular release.

All versions of iMacros insert a BOM at the beginning of UTF-8 output files created with SAVEAS TYPE=EXTRACT. This is common practice and is not likely to change.
Regards,

Tom, iMacros Support
rs904c
Posts: 5
Joined: Tue Apr 14, 2015 1:41 am

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by rs904c » Fri Apr 17, 2015 2:09 am

Why does it do that? Not everyone wants that, it should be a choice.

Can we get a setting under options to turn this on/off with a check box?
Tom, Tech Support
Posts: 3609
Joined: Mon May 31, 2010 4:59 pm

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by Tom, Tech Support » Mon Apr 20, 2015 11:30 am

rs904c wrote:Why does it do that? Not everyone wants that, it should be a choice.

Can we get a setting under options to turn this on/off with a check box?
Would you please start a new thread for this topic and state your case for not wanting the BOM.
Regards,

Tom, iMacros Support
rs904c
Posts: 5
Joined: Tue Apr 14, 2015 1:41 am

Re: Error NS_ERROR_UNEXPECTED in Firefox 28 - SOLVED!

Post by rs904c » Mon Apr 20, 2015 10:13 pm

Since iMacro won't fix this, I went ahead and wrote a perl script to fix this.

The following perl script will remove the BOM, <EF><BB><BF> from the beginning of every .txt file in the path directory.
This should work with csv files too.

Code: Select all

#!/usr/bin/perl
$path='C:\path-where-the-bom-files-are';

opendir($listoffiles, $path) || die "\aProblem opening that directory.\n";
@arrayfiles = readdir($listoffiles);
foreach $ffile (sort @arrayfiles)
{
	if (-d "$path\\$ffile")  # if it is a directory, next
	{
	next;
	}
	if (-f "$path\\$ffile") # if it is a file
	{
		if ((substr $ffile, -4) eq ".txt")
		{
		print "Found a text file and it's name is: $ffile \n";	
		open ($input_handle,"$path\\$ffile");
		@lines=<$input_handle>;
		close ($input_handle);
		open ($output_handle,">$path\\$ffile");
		foreach $line (@lines) 
		{
			$line =~ s/^\xEF\xBB\xBF//; #remove Byte Order Mark
			print $output_handle $line;
		}
		}
		
	}
}
closedir($listoffiles);

Post Reply