incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christiaan van Zyl (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-1666) [weinre] "INVALID_STATE_ERR: DOM Exception 11" with chbrody/Cordova-SQLitePlugin
Date Thu, 18 Oct 2012 09:06:03 GMT

     [ https://issues.apache.org/jira/browse/CB-1666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Christiaan van Zyl updated CB-1666:
-----------------------------------

    Comment: was deleted

(was: I've managed to separate out the code and created a test page, see [1]. Not sure how
to attach files?

Running this page with weinre 2.0.0-pre-H41DGW8S-incubating I get the error as described above
intermittently. When I comment out the weinre include script I do not get the error.

Running this page with the patch 2.0.0-pre-H8EOSCLN-incubating I do not get the error, but
the connection to weinre dies after running the test a couple of times.

I guess it might also be some bug in my code below or the plugin...

[1]

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
    <script src="external/Cordova-SQLitePlugin/iOS/www/SQLitePlugin.js"></script>
    <script src="http://192.168.1.169:1337/target/target-script-min.js#anonymous"></script>
</head>
<body>

<a href="javascript:" onclick="fRunTest();">Run Test</a>

<script>
    window.onerror = function(sMessage, sFileName, nLineNumber) {
        alert(sMessage + " " + sFileName + " " + nLineNumber)
    };

    /**
     * Insert rows into specified table.
     * @param {string} sTableName
     * @param {object[]} aRows
     * @param {function} fCallback
     */
    fInsertRows = function(sTableName, aRows, fCallback) {
        var db = window.sqlitePlugin.openDatabase("sqlite.db", "1.0", "Application Data",
20000);
        db.transaction(function(tx) {
            tx.executeSql(
                'CREATE TABLE IF NOT EXISTS ' + sTableName + ' (' +
                'id integer primary key, ' +
                'value text)'
            );
        });

        var fLoop = function() {
            var Row = aRows.shift();
            var nRows = aRows.length;
            var sColumns = "";
            var sPlaceholders = "";
            var aValues = [];
            for (var sColumnName in Row) {
                var value = Row[sColumnName];
                if (sColumns.length > 0) {
                    sColumns += ", ";
                    sPlaceholders += ", ";
                }
                sColumns += sColumnName;
                sPlaceholders += "?";
                aValues.push(value);
            }

            var fError = function(e) {
                alert(JSON.stringify(e, null, 2));
            };

            db.transaction(function(tx) {
                tx.executeSql(
                    "insert into " + sTableName + " (" + sColumns + ") values (" + sPlaceholders
+ ")",
                    aValues,
                    function() {
                        if (nRows > 0) {
                            fLoop();
                        } else {
                            fCallback();
                        }
                    },
                    fError
                );
            });
        };
        fLoop();
    };

    function fRunTest() {
        fInsertRows(
            "test",
            [
                {
                    "value": "1234567890"
                },
                {
                    "value": "aaaaaaaaaaa"
                }
            ],
            function() {
                alert("done");
            }
        );
    }

    // Wait for Cordova to load
    document.addEventListener(
        "deviceready",
        function() {
            alert("ready");
        },
        false
    );
</script>

</body>
</html>


)
    
> [weinre] "INVALID_STATE_ERR: DOM Exception 11" with chbrody/Cordova-SQLitePlugin
> --------------------------------------------------------------------------------
>
>                 Key: CB-1666
>                 URL: https://issues.apache.org/jira/browse/CB-1666
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: weinre
>    Affects Versions: 2.1.0
>         Environment: OS X Lion 10.7.4, Google Chrome 22.0.1229.94, iOS6 iPhone Simulator
>            Reporter: Christiaan van Zyl
>            Assignee: Patrick Mueller
>
> When using weinre with Cordova-SQLitePlugin we get a javascript error:
> "INVALID_STATE_ERR: DOM Exception 11: An attempt was made to use an object that is not,
or is no longer, usable. File: http://192.168.1.169:1337/target/target-script-min.js?_=1350463351336
Line Number: 2794"
> Above line number corresponds to the function NetworkRequest.prototype.handleDone in
target-script-min.js.
> As a work around I have just wrapped a try catch and made it fail silently:
> NetworkRequest.prototype.handleDone = function() {
>     try {
>         var description, sourceString, status, statusText, success, time;
>         sourceString = this.xhr.responseText;
>         Weinre.wi.NetworkNotify.setInitialContent(this.id, sourceString, "XHR");
>         time = Date.now() / 1000.0;
>         status = this.xhr.status;
>         if (status === 0) {
>             status = 200;
>         }
>         statusText = this.xhr.statusText;
>         success = status >= 200 && status < 300;
>         if (success) {
>             return Weinre.wi.NetworkNotify.didFinishLoading(this.id, time);
>         } else {
>             description = "" + status + " - " + statusText;
>             return Weinre.wi.NetworkNotify.didFailLoading(this.id, time, description);
>         }
>     } catch (e) {
>         return;
>     }
> };

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message