Skip to content

Commit

Permalink
[test] Add test for issue #5943
Browse files Browse the repository at this point in the history
- This case is failed on failed version 0.23.0, pass on fixed version 0.27.4
  • Loading branch information
wanghongjuan committed Jan 24, 2018
1 parent 65cc2f4 commit 368a6d2
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Program: 5DBat - by BlatSoft
// 04/2017 version: 0.1.0
// dbcontrol.js
// This file used to control all database functions
// - Called from end of start.html/running.html

"use strict";

var dblite = require('dblite');

var dbPath = 'dogs.db';

// ********************** Define SQLite bin path **************************
//dblite.bin = "node_modules/sqlite3/sqlite3"; // if not specified then default install will be used if exists (/usr/local/bin/sqlite3)


//######################################################################################################
//# DB Connect (dblite)
//######################################################################################################
/**
* Connect Database
* @param dbPath
*
*/
//var db = function connectDb(dbPath) {
var db = dblite(dbPath); // creates if no exist

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"app_name": "5943",
"name": "issue5943-mac-dblite-module-with-node8-crash",
"description": "Crash with nwjs 0.23.0 with node 8.0.0pre",
"single-instance": true,
"version": "0.1.0",
"chromium-args": "--enable-logging",
"main": "start.html",
"window": {
"resizable": true,
"visible": true,
"exe_icon": "",
"icon": "",
"width": 1400,
"show_in_taskbar": true,
"always_on_top": false,
"mac_icon": "",
"title": "dblitekrash0230",
"height": 850,
"show": true,
"fullscreen": false
},
"webkit": {
"plugin": true
},
"webview": {
"partitions": [
{
"name": "trusted",
"accessible_resources": [
"<all_urls>"
]
}
]
},
"additional_trust_anchors": [
""
],
"dependencies": {
"dblite": "^0.7.9"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
// Program: game - by BlatSoft
// 05/2017 version: 0.7.0
// start.html
// This page is first screen on game start - used to set up game/teams/etc ready for play
// - Called from package.json
-->
<head>
<title>issue5943-mac-dblite-module-with-node8-crash</title>
<script type="text/javascript" src="dbcontrol.js" charset="utf-8"></script>

</head>

<body>

<div id="head">
<h1>dblitekrash0230node8</h1>
<div id="versions">
NWjs version -
<script>
document.write(process.versions['nw']);
</script><br /> IO.js/node.js version -
<script>
document.write(process.versions['node']);
</script><br /> Chromium version -
<script>
document.write(process.versions['chromium']);
</script><br />
</div>

</div>
<div id="shell"></div>

<!-- End of HTML ********************************** -->

<script type="text/javascript">

var show = ''; // = new Array();
db.query('SELECT rowid, Cap, Dog FROM ' + 'Australia',['id', 'cap', 'dog'],
// once retrieved
function(rows) {
for (var i = 0, len = rows.length; i < len; i++) {
var str = rows[i].dog; // used for populating optionlist
console.log(str);
show = show + str + '<br />';
}
document.getElementById('shell').innerHTML = show;
}
);
</script>

</body>
</html>

45 changes: 45 additions & 0 deletions test/sanity/issue5943-mac-dblite-module-with-node8-crash/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import time
import os
import shutil
import platform
import sys
import subprocess

#if platform.system() != 'Darwin':
# print 'Skipped for non Mac platform'
# sys.exit(0)

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
testdir = os.path.dirname(os.path.abspath(__file__))
chrome_options.add_argument("nwapp=" + testdir)
node_module = os.path.join(testdir, "node_modules")
os.chdir(testdir)

#try:
# shutil.rmtree(node_module)
#except:
# pass
#
#assert(False == os.path.isdir(node_module))
#subprocess.call(["npm", "install", "dblite"])

#assert(os.path.isdir(node_module))

install_native_modules()

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
driver.implicitly_wait(2)
try:
print driver.current_url
print "select data from table Australia"
result = driver.find_element_by_id("shell").get_attribute("innerHTML")
assert("Sausage" in result)
print 'There is no crash'
finally:
driver.quit()

0 comments on commit 368a6d2

Please sign in to comment.