EEXCESS / chrome-extension

Chrome extension for displaying cultural and scientific resources in the context of a web page. The extension integrates other modules like C4, the Visualization Widgets and PEAS.
2 stars 2 forks source link

When QueryCrumbs History load fails, paragraph detection is also broken #50

Closed mgrani closed 9 years ago

mgrani commented 9 years ago

I have been switching to the developer version from the web store version in order to test a new feature (version 92ae5c8). It seemed that the query crumbs search history failed to load (see below).

It would seem a good idea to make the code more secure here.

Exception:

Error in response to storage.get: TypeError: Cannot read property 'slice' of undefined
at eval (eval at <anonymous> (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/requireContent.js:7:21), <anonymous>:551:49)
at Object.callback (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/content.js:142:37)
at Object.chrome.storage.sync.get.searchBar.init.queryCrumbs.storage.getHistory [as getHistoryCallback] (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/content.js:141:54)
at Object.init (eval at <anonymous> (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/requireContent.js:7:21), <anonymous>:541:18)
at Object.init (eval at <anonymous> (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/requireContent.js:7:21), <anonymous>:439:20)
at chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/content.js:125:27
at Object.context.execCb (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/lib/requirejs/require.js:1678:33)
at Object.Module.check (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/lib/requirejs/require.js:878:51)
at Object.<anonymous> (chrome-extension://gieldaokbpofcmgipcgoejicflmfnhmc/js/lib/requirejs/require.js:1128:34)

Source Code:

storage: {
                        getHistory: function(callback) {
                            chrome.storage.local.get('queryCrumbs_history', function(res) {
                                callback(res.queryCrumbs_history); //here the exception happens
                            });
                        },
                        setHistory: function(history) {
                            chrome.storage.local.set({queryCrumbs_history: history});
                        }
                    },

And the callback:

 self.getHistoryCallback(function(loadedHistory) {
            if (typeof loadedHistory === 'undefined' || loadedHistory === null) {
                loadedHistory = {
                    history: [],
                    base_color: QueryCrumbsConfiguration.BaseColorManager.getInitialColor(),
                    currentQueryID: -1
                };
            }
            self.base_color = loadedHistory.base_color;
            var currentQueryID = loadedHistory.currentQueryID;
            var hist = loadedHistory.history.slice(Math.max(loadedHistory.history.length - QueryCrumbsConfiguration.dimensions.HISTORY_LENGTH, 0));
            self.visualData = [];
            for (var nodeIdx = 0; nodeIdx < hist.length; nodeIdx++) {
                self.CORE.addVisualNode(hist[nodeIdx]);
            }
            self.RENDERING.redraw(self.visualData);
            self.RENDERING.setCurrentQuery(currentQueryID);
        });
    },

The error occures in var hist = loadedHistory.history.slice(Math.max(loadedHistory.history.length - QueryCrumbsConfiguration.dimensions.HISTORY_LENGTH, 0));

mgrani commented 9 years ago

add on: it did not cause the problem that the paragraph detection no longer worked (that seems to be something different). However, the bug with loading is there. (i resolved it by clearing query crumbs history)

mgrani commented 9 years ago

add on: stupid i am. forgot bower update twice. now everything works. I leave the bug open since we have another query crumbs bug, where the qc suddenly disappear. Maybe this one is realted. if not, please close it.

schloett commented 9 years ago

They probably are related, the problem seemed to be caused by the storage handling in the extension. Should be fixed now, see issue #49.