edgi-govdata-archiving / eot-nomination-tool

📚 Chrome extension to nominate government data that needs to be preserved
https://chrome.google.com/webstore/detail/nominationtool/abjpihafglmijnkkoppbookfkkanklok
GNU General Public License v3.0
20 stars 10 forks source link

Javascript syntax error keeps tool from working in older operating systems #68

Closed dorasmith closed 7 years ago

dorasmith commented 7 years ago

The NominationTool appears to have a javascript syntax error that causes the tool to fail to run in Chrome on some older computers.

I ran into this at the data rescue event in my city, where I found that the tool wouldn't work on my older 32 bit, lightweight Ubuntu laptop, which is my only laptop, used on the rare occasions when I don't have access to my desktop computers, and my Android tablet or my phone won't do.

Specifically, the browser extension pops up the web form. The form displays all fields that should display. It displays the message that this web site has previously been nominated in the past 30 days in red text, all of the time, even when it is highly unlikely or not possible that the web site was submitted to the End of Term project; for instance, my personal web site tiggernut.com . Nothing autopopulates that should autopopulate; the web page url, the web page title, the agency name, and the name and email as entered on the form previously, are not populated. Finally, when you click the submit button, the data gathered on the page appears to submit, but the data does not actually appear in the remote Google docs spreadsheet that the data is saved to. In short, none of the interactive and decisionmaking capability of the web page works, which leaves one wondering if the javascript is working at all.

The problem is replicated on my 32 bit full Ubuntu 14.04 installation with all bells and whistles, such as several versions of Java up to date, and Flash, installed. It also is replicated on the same Chrome version in Windows XP.

The Chrome extension works perfectly on my Windows 7 computer, and in Windows XP once I upgraded to version 49 of Chrome.

Chrome has discontinued support for 32 bit Linux. The last version of Chrome that is available for for 32 bit Linux is version 48, which came out about February of 2016.

Chrome has also discontinued support for Windows XP, Windows Vista, and Mac operating system versions 10.6 through 10.8, effective later in 2016. The last version of Chrome that can be installed on these operating systems is version 49, which came out in March of 2016. When I tried to install the current version of Chrome on Windows XP, version 49 is what installed. This means that Windows XP and Vista users will get version 49 by updating their browser, but otherwise needing a single version a year old that works with the tool is probably beyond most peoples' capacity.

At the same time, Chrome has deleted a lot of functionality from older operating systems, including the ability to use gmail webmail in Windows XP and Vista. These were major changes in Chrome functionality, and they prevent so many people from using Chrome and other Google features, like gmail, that they appear self destructive.

To review, here is what the tool does and does not work in:

The last version of Chrome for 32 bit Linux is version 48, and the Chrome extension does not work in it.
The last version of Chrome for Windows XP, Vista, and Mac 10.6-8 is version 49, and the tool works for it.
The chrome extension works perfectly in the current version of Chrome, I think 56, in Windows 7.

By working, I mean that the tool loads the previously nominated warning only as appropriate, all autopopulation takes place, and Maya and Dawn have confirmed that the web site information is actually submitting, though I don't in every case have a per operating system breakdown of what submitted.

I had to jump through about twenty hoops to learn if this could be a product of the system requirements of the Chrome extension. One of the coders, Michelle Lee, told me that as far as the coders know, this tool should work on any computer that runs Chrome, in any version of Chrome. It doesn't need something else, like java or flash, and the only OS it shouldn't be expected to run on is Android. Android does not support Chrome extensions of any sort.

It is very important that the tool work on older computers. The End of Term nomination page is not a suitable substitute, because it can neither nominate uncrawlable web pages, interactive tools and data, but it can't capture the basic information about what is uncrawlable that the Chrome extension captures. Anyone told to use that page instead has basically been told not to particpate in the project. You can't nominate much of anything at all with it, and when I actually tried, I was soon very frustrated by my obvious failure to capture all of the really interesting educational material about climate change that these federal government web sites have on them.

The kind of people likely to participate in a project to protect scientific data and information from the new federal government, are also very likely to have older computers and to use Linux. This is especially true around Austin, Texas, where a very large proportion of the population, even the working class, have computer assembly and computer skills. Contributing to it is that fact that the newest versions of Windows are so bad that they are downright unusable. I was struck by the fact that every single person in the room except me at my event actually had a Mac. Most people can't afford a Mac. Windows 8 and 10 systems are hard to use, their desktops are childish and gaudy, and they self destruct regularly, often when they automatically install Windows updates. These operating systems aren't popular, and for most the alternative is Linux. When I used to do marketing phone surveys, and ask people what brands of computers they had, about half those around Austin said they built their own. This is not a city of people who can be counted on to show up to events carrying laptops they paid $700 for new at a store.

Checking and debugging the javascript used by the tool confirms that this is some sort of javascript failure.

The coders on this project will know this; others won't. A Google Chrome extension primarily works on javascript, with some HTML. This tool has in its folder the popup.html web form, the popup.css stylesheet that contains the formatting for the web form, a manifest.json file found in every Google Chrome extension folder that describes what the tool does and gives permissions to its constituent files, a long popup.js file that does most of the functionality of the popup web form, two smaller javascript files that it calls, and a local copy of a jquery library that it calls. The two smaller javascripts mostly call Google Chrome APIs, which are javascript functions provided for Google Chrome extensions, and luckily this tool systematically calls all of them Chrome.whatEver.whatEver.

Google Chrome provides several methods to debug Chrome extensions. I enabled developer mode on the chrome:\extensions page, and then loaded the unpacked folder. One can then view the contents of each file in a console. When I did this I got just one error. "Failed to load extension from /home/dora/Desktop/0.0.6_0. Cannot load extension with file or directory name metadata. Filenames starting with "" are reserved for use by the system." This error is sort of strange, since every javascript text, teaching app and book I've rounded up in the past two days say that a javascript name can legally start with _ , or a letter, or a $. Perhaps not in the Google world?

The good news about this error is that it also occurs on my Windows 7 computer with the current version of Chrome, and even though the file names are allegedly illegal and the tool allegedly won't load, it still works. The two folders whose names start with underscores contain the jquery library, which is a javascript library, and two files that seem to apply hash marks and whatever to checking the integrity of files; it is not clear what their function is.

I also checked the tool for errors by right clicking on the extension icon in the browser toolbar, and selecting Inspect popup. This also opens a console, with multiple tabs that contain information, but in the console window is an error message:

(x) "Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) popup.js:15 not yet supported outside strict mode".

The exact syntax of the error message varies; another has (let, const, function, popup.js:15 class).

This error reads true. For one thing, a syntax error is very consistent with the apparent failure of the javascripts to do anything at all. A syntax error causes a program to fail to run.

It logically looks as though something changed in what is supported outside strict mode by Google Chrome, between February and March of 2016.

That something could have been the uneven advent of a new version of the core java standard throughout 2015 and 2016, that changed how strict mode works. One effect was that things that used to work now specifically provide this syntax error.

Michelle Lee appears to think that somehow, if I understood her correctly (and it's possible I didn't), that even though I understand that the Chrome extension was written in November of 2016, in a big hurry, and more than likely in the then current standard, someone involved with this project rewrote the code to conform to the new javascript standard, which is now causing the error when older browsers reject it.

If that is true, there may be a copy of the original code around somewhere, and it's worth testing it to see if it works.

This error is often solved by simply putting a line of code at the beginning of each file or function, before any code, telling it to run in strict mode. That can fail to work if features of the code won't work in strict mode, and there is also something about the measure needing to applied to all of the javascript files. I tried it, but couldn't get it to work. What is more it still gives me the same error message, even after clearing the browser cache. It is possible I'm doing something wrong. If I did it right but it didn't work, I should be getting different error messages about illegal code, not a message that tells me I'm not in strict mode.

In particular, one thing that could have gone wrong, is variables not declared according to the standard, another is things about how variables are passed between functions and files, and javascript is at its most obtuse at both. In particular I've never been able to follow inheritance in my life. It could also be the constant use of the words const, function and class. My workaround should have gotten around that, but I'm not sure my workaround worked properly.

I can't easily fix this any further since I don't know javascript. I am sure I could learn enough javascript to solve the problem, in a couple of months, having previously learned enough to debug programs by reading the book, but I don't have the time. I also can't make head or tail of the github system for submitting my changes, and it seems to be rather hard to get things explained here.

One thing I can do is test code that people send me. It does, however, appear that this problem will occur in version 48 of Chrome on any operating system.

There is also a workaround for the problem, and Dawn wanted that I should share it. This is not the first time a Google Chrome extension ever failed to work in Chrome. The extension won't work in 32 bit Linux thing is a particularly common problem. The Chrome NominationTool extension can be installed from the Google extension store into the Opera Browser. I tried it, it works, and it has been verified to actually submit data to the Google Doc spreadsheet. The Opera Browser runs off of the Chrome engine, or something of the sort, and its extensions use many of the same APIs. You first install the Chrome Extension directly from the Opera extension store. https://addons.opera.com/en/extensions/details/download-chrome-extension-9/ . Then you go to the NominationTool in the Google extension store. click "Add to Opera". Then find it in opera://extensions, and click "install". Then you will see the magnifying glass icon in the right on the tool bar, just as in Chrome.

dcwalk commented 7 years ago

Hey @dorasmith it looks like @mi-lee is looking at a fix in #67! We can/should update documentation as a part of that

atesgoral commented 7 years ago

@dorasmith Thanks a lot for this very detailed problem report/analysis. It was I who falsely assumed that, since Chrome gets automatically updated, most users should on the most recent version of Chrome. We're dropping the use of ES6. We still might have issues with CSS flexbox and CSS transformation, but those will be largely visual issues that won't affect the tool from functioning. I'm looking into removing the use of flexbox and also finding a decent fallback for the CSS transformations.

dorasmith commented 7 years ago

Thanks, all. I saw the work in issue 67 as well. I guess the problem is that the program was either rewritten or compiled in ES6. That makes more sense than ES5, which seems too old.

Researching that, Strict code was introduced in ES5, and changed radically in ES6. Block code allegedly did not exist in javascript until ES6.

I just got specifics about the causes of the error from @atesgoral, it wouldn't have been fair for someone who doesn't know javascript to ask here. I could use to know the basics for more than one reason. I got some texts that were published before ES6, and ES6 introduced very obvious programming features javascript programmers have always wanted. Some of them made the rewritten tool not work when the browser uses ES5.

Thanks a lot!

dcwalk commented 7 years ago

@dorasmith -- the changes have been merged in. Could you test with the update extension and let us know if you still experience issues?

dorasmith commented 7 years ago

So far it isn't working. In Windows XP it may have developed a new bug - a four hour old CNN page about Russia shows as having been archived before.

But I notice that the different versions of Chrome give me different information. I reinstalled it in my current version of Chrome in Windows 7, and it's telling me the extension was last updated on February 10. Are you sure you uploaded the updated version to the Chrome store?

dorasmith commented 7 years ago

Actually, it is in the Chrome store that it says it was last updated on February 10.

dorasmith commented 7 years ago

Do me a favor. Before you upload it again, change a file, like the license, or the readme, with the current date or something, so I can tell I've actually got the current version installed. Or put a comment with the date it was updated in popup.js . Because the next thing I'm going to do is compare it with the old version.

dorasmith commented 7 years ago

I've got an idea I got the old version from the Chrome store. Atesgoral mentioned that const args = arguments is an example of one of the new javascript version features that caused the problem - and it's still there. It's in the first function.

dcwalk commented 7 years ago

Sorry, I thought the changes had been published right after being merged. Had my wires crossed. I'm showing 0.0.7 on Feb 18 is in the Chrome Store

dorasmith commented 7 years ago

It appears to work. I just submitted http://freepages.genealogy.rootsweb.ancestry.com/~villandra, Ancestors of Michael McKinstry, at about 10:50 AM. If someone could check and make sure it submitted.

dcwalk commented 7 years ago

I confirmed the page was added, glad to have this resolved! I'm closing this issue as fixed 🎉

dorasmith commented 7 years ago

Thanks a lot, all! :)