Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
eaaee736
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
eaaee736
编写于
6月 14, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 14, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8967 test:add webstorage testcase
Merge pull request !8967 from 李伟明/webview
上级
c7dd2370
bd29e310
变更
7
展开全部
显示空白变更内容
内联
并排
Showing
7 changed file
with
951 addition
and
3 deletion
+951
-3
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/onWindowNew.ets
...ller/entry/src/main/ets/MainAbility/pages/onWindowNew.ets
+21
-1
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webStorage.ets
...oller/entry/src/main/ets/MainAbility/pages/webStorage.ets
+534
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets
...v_webviewController/entry/src/main/ets/test/List.test.ets
+2
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/WebViewOnWindowNewJsunit.test.ets
...entry/src/main/ets/test/WebViewOnWindowNewJsunit.test.ets
+13
-1
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/WebViewWebStorageJsunit.test.ets
.../entry/src/main/ets/test/WebViewWebStorageJsunit.test.ets
+340
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json
...ler/entry/src/main/resources/base/profile/main_pages.json
+2
-1
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/getOrigins.html
...ntroller/entry/src/main/resources/rawfile/getOrigins.html
+39
-0
未找到文件。
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/onWindowNew.ets
浏览文件 @
eaaee736
...
@@ -32,7 +32,7 @@ struct OnWindowNew {
...
@@ -32,7 +32,7 @@ struct OnWindowNew {
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State userAgent:string = "Mozilla/5.0 (Window NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) CHrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27";
@State javaScriptAccess:boolean=true;
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=
fals
e;
@State domStorageAccess:boolean=
tru
e;
@State imageAccess:boolean=true;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State databaseAccess:boolean=true;
...
@@ -153,6 +153,26 @@ struct OnWindowNew {
...
@@ -153,6 +153,26 @@ struct OnWindowNew {
}
}
break;
break;
}
}
case "emitGetOriginsPromiseLoadLocalHtml01": {
let length = -1;
try {
this.controller.loadUrl($rawfile('getOrigins.html'));
web_webview.WebStorage.getOrigins()
.then(origins => {
console.log(`getOrigins call`);
if (origins) {
length = origins.length;
console.log(`length is: ${length}`);
}
console.log(`getOrigins call end`);
Utils.emitEvent(length, 7166);
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
Utils.emitEvent(length, 7166);
}
break;
}
}
}
})
})
}
}
...
...
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webStorage.ets
0 → 100644
浏览文件 @
eaaee736
此差异已折叠。
点击以展开。
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets
浏览文件 @
eaaee736
...
@@ -19,6 +19,7 @@ import webViewOnErrorReceive03Jsunit from './WebViewOnErrorReceive03Jsunit.test'
...
@@ -19,6 +19,7 @@ import webViewOnErrorReceive03Jsunit from './WebViewOnErrorReceive03Jsunit.test'
import webViewHasImageJsunit from './webViewHasImageJsunit.test'
import webViewHasImageJsunit from './webViewHasImageJsunit.test'
import webViewSrollToJsunit from './webViewSrollToJsunit.test'
import webViewSrollToJsunit from './webViewSrollToJsunit.test'
import webViewSrollByJsunit from './webViewSrollByJsunit.test'
import webViewSrollByJsunit from './webViewSrollByJsunit.test'
import WebViewWebStorageJsunit from './WebViewWebStorageJsunit.test'
export default function testsuite() {
export default function testsuite() {
webViewControllerJsunit()
webViewControllerJsunit()
webViewOnWindowNewJsunit()
webViewOnWindowNewJsunit()
...
@@ -27,4 +28,5 @@ export default function testsuite() {
...
@@ -27,4 +28,5 @@ export default function testsuite() {
webViewHasImageJsunit()
webViewHasImageJsunit()
webViewSrollToJsunit()
webViewSrollToJsunit()
webViewSrollByJsunit()
webViewSrollByJsunit()
WebViewWebStorageJsunit()
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/WebViewOnWindowNewJsunit.test.ets
浏览文件 @
eaaee736
...
@@ -148,9 +148,21 @@ export default function webViewOnWindowNewJsunit() {
...
@@ -148,9 +148,21 @@ export default function webViewOnWindowNewJsunit() {
*tc.desc test api blockNetWork set to false by load online website
*tc.desc test api blockNetWork set to false by load online website
*/
*/
it('testBlockNetWorkFalse',0,async function(done){
it('testBlockNetWorkFalse',0,async function(done){
emitKey="emitGetOriginsPromiseLoadLocalHtml01";
let title = "www.weibo.com";
let title = "www.weibo.com";
Utils.registerEvent("testBlockNetWorkFalse", title, 7114, done);
Utils.registerEvent("testBlockNetWorkFalse", title, 7114, done);
sendEventByKey('onWindowNew', 10, '');
sendEventByKey('onWindowNew', 10, '');
})
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0100
*tc.name testGetOriginsPromiseLoadLocalHtml01
*tc.desc test api GetOrigins promise mode by load loacal html
*/
it('testGetOriginsPromiseLoadLocalHtml01', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadLocalHtml01';
let length = 1;
Utils.registerEvent("testGetOriginsPromiseLoadLocalHtml01", length, 7166, done);
sendEventByKey('onWindowNew', 10, '');
})
})
})
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/WebViewWebStorageJsunit.test.ets
0 → 100644
浏览文件 @
eaaee736
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = 'emitGetOriginsCallbackLoadWebkit';
export default function WebViewWebStorageJsunit() {
describe('actsAceWebViewWebStorageJsunit', function () {
beforeEach(async function (done) {
let options = {
uri: "MainAbility/pages/webStorage"
}
try {
router.clear();
let pages = router.getState();
console.info("get webStorage state success " + JSON.stringify(pages));
if (!("webStorage" == pages.name)) {
console.info("get webStorage state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webStorage page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webStorage page error: " + err);
}
await Utils.sleep(2000);
done()
})
afterEach(async function (done) {
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0100
*tc.name testGetOriginsCallbackLoadWebkit01
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].origin when load website which
* address is 'https://webkit.org/demos/sticky-notes/index.html'
*/
it('testGetOriginsCallbackLoadWebkit01', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadWebkit02';
let origin = 'https://webkit.org/';
Utils.registerEvent("testGetOriginsCallbackLoadWebkit01", origin, 7136, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0200
*tc.name testGetOriginsCallbackLoadWebkit02
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].usage when load website which
* address is 'https://webkit.org/demos/sticky-notes/index.html'
*/
it('testGetOriginsCallbackLoadWebkit02', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadWebkit03';
let usage = 24576;
Utils.registerEvent("testGetOriginsCallbackLoadWebkit02", usage, 7138, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0300
*tc.name testGetOriginsCallbackLoadWebkit03
*tc.desc test api getOrigins callback mode by the value 0f checking Origins[0].quote when load website which
* address is 'https://webkit.org/demos/sticky-notes/index.html'
*/
it('testGetOriginsCallbackLoadWebkit03', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadWebkit01';
let quota = 4054614016;
Utils.registerEvent("testGetOriginsCallbackLoadWebkit03", quota.toString(), 7140, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0400
*tc.name testGetOriginsPromiseLoadWebkit01
*tc.desc test api getOrigins promise mode by checking the value 0f Origins[0].origin when load website which address
* is 'https://webkit.org/demos/sticky-notes/index.html'
*/
it('testGetOriginsPromiseLoadWebkit01', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadWebkit02';
let origin = 'https://webkit.org/';
Utils.registerEvent("testGetOriginsPromiseLoadWebkit01", origin, 7142, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0500
*tc.name testGetOriginsPromiseLoadWebkit02
*tc.desc test api getOrigins promise mode by checking the value 0f Origins[0].usage when load website which address
* is 'https://webkit.org/demos/sticky-notes/index.html'
*/
it('testGetOriginsPromiseLoadWebkit02', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadWebkit03';
let usage = 24576;
Utils.registerEvent("testGetOriginsPromiseLoadWebkit02", usage, 7144, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0600
*tc.name testGetOriginsPromiseLoadWebkit03
*tc.desc test api getOrigins promise mode by the value 0f checking Origins[0].quote when load website which address
* is 'https://webkit.org/demos/sticky-notes/index.html'
*/
it('testGetOriginsPromiseLoadWebkit03', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadBaidu01';
let quota = 4054614016;
Utils.registerEvent("testGetOriginsPromiseLoadWebkit03", quota.toString(), 7146, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0700
*tc.name testGetOriginsCallbackLoadBaidu01
*tc.desc test api getOrigins callback mode by checking the length of origins when load website which address
* is 'https://www.baidu.com'
*/
it('testGetOriginsCallbackLoadBaidu01', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadBaidu02';
let length = 1;
Utils.registerEvent("testGetOriginsCallbackLoadBaidu01", length, 7148, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0800
*tc.name testGetOriginsLoadBaidu02
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].usage when load website which address
* is 'https://www.baidu.com'
*/
it('testGetOriginsCallbackLoadBaidu02', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadBaidu03';
let usage = 24576;
Utils.registerEvent("testGetOriginsCallbackLoadBaidu02", usage, 7150, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_0900
*tc.name testGetOriginsCallbackLoadBaidu03
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].quota when load website which address
* is 'https://www.baidu.com'
*/
it('testGetOriginsCallbackLoadBaidu03', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadBaidu01';
let quota = 4054614016;
Utils.registerEvent("testGetOriginsCallbackLoadBaidu03", quota.toString(), 7152, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1000
*tc.name testGetOriginsPromiseLoadBaidu01
*tc.desc test api getOrigins Promise mode by checking the length of origins when load website which address
* is 'https://www.baidu.com'
*/
it('testGetOriginsPromiseLoadBaidu01', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadBaidu02';
let length = 1;
Utils.registerEvent("testGetOriginsPromiseLoadBaidu01", length, 7154, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1100
*tc.name testGetOriginsPromiseLoadBaidu02
*tc.desc test api getOrigins Promise mode by checking the value 0f Origins[0].usage when load website which address
* is 'https://www.baidu.com'
*/
it('testGetOriginsPromiseLoadBaidu02', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadBaidu03';
let usage = 24576;
Utils.registerEvent("testGetOriginsPromiseLoadBaidu02", usage, 7156, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1200
*tc.name testGetOriginsPromiseLoadBaidu03
*tc.desc test api getOrigins Promise mode by checking the value 0f Origins[0].quota when load website which address
* is 'https://www.baidu.com'
*/
it('testGetOriginsPromiseLoadBaidu03', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadLocalHtml01';
let quota = 4054614016;
Utils.registerEvent("testGetOriginsPromiseLoadBaidu03", quota.toString(), 7158, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1300
*tc.name testGetOriginsCallbackLoadLocalHtml01
*tc.desc test api getOrigins callback mode by checking the length of origins when load local html
*/
it('testGetOriginsCallbackLoadLocalHtml01', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadLocalHtml02';
let length = 1;
Utils.registerEvent("testGetOriginsCallbackLoadLocalHtml01", length, 7160, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1400
*tc.name testGetOriginsLoadCallbackLocalHtml02
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].usage when load local html
*/
it('testGetOriginsLoadCallbackLocalHtml02', 0, async function(done){
emitKey = 'emitGetOriginsCallbackLoadLocalHtml03';
let usage = 24576;
Utils.registerEvent("testGetOriginsLoadCallbackLocalHtml02", usage, 7162, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1500
*tc.name testGetOriginsCallbackLoadLocalHtml03
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].quota when load local html
*/
it('testGetOriginsCallbackLoadLocalHtml03', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadLocalHtml02';
let quota = 4054614016;
Utils.registerEvent("testGetOriginsCallbackLoadLocalHtml03", quota.toString(), 7164, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1600
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1700
*tc.name testGetOriginsPromiseLoadLocalHtml02
*tc.desc test api getOrigins callback mode by checking the value 0f Origins[0].usage when load local html
*/
it('testGetOriginsLoadPromiseLocalHtml02', 0, async function(done){
emitKey = 'emitGetOriginsPromiseLoadLocalHtml03';
let usage = 24576;
Utils.registerEvent("testGetOriginsPromiseLoadLocalHtml02", usage, 7168, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1800
*tc.name testGetOriginsPromiseLoadLocalHtml03
*tc.desc test api getOrigins Promise mode by checking the value 0f Origins[0].quota when load local html
*/
it('testGetOriginsPromiseLoadLocalHtml03', 0, async function(done){
emitKey = 'emitDeleteOrigin';
let quota = 4054614016;
Utils.registerEvent("testGetOriginsPromiseLoadLocalHtml03", quota.toString(), 7170, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_1900
*tc.name testDeleteOrigin
*tc.desc test api deleteOrigin by checking the value 0f getOriginUsage when delete 'resource://rawfile/'
*/
it('testDeleteOrigin', 0, async function(done){
emitKey = 'emitDeleteAllData';
let usage = 0;
Utils.registerEvent("testDeleteOrigin", usage, 7172, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_2000
*tc.name testDeleteAllData
*tc.desc test api deleteAllData by checking the value 0f getOriginUsage when delete 'resource://rawfile/'
*/
it('testDeleteAllData', 0, async function(done){
emitKey = 'emitGetOriginQuotaCallback';
let usage = 0;
Utils.registerEvent("testDeleteAllData", usage, 7174, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_2100
*tc.name testGetOriginQuotaCallback
*tc.desc test api getOriginQuota callbcak mode by load loacal html
*/
it('testGetOriginQuotaCallback', 0, async function(done){
emitKey = 'emitGetOriginQuotaPromise';
let quota = 4054614016;
Utils.registerEvent("testGetOriginQuotaCallback", quota.toString(), 7176, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_2200
*tc.name testGetOriginQuotaPromise
*tc.desc test api getOriginQuota callbcak mode by load loacal html
*/
it('testGetOriginQuotaPromise', 0, async function(done){
emitKey = 'emitGetOriginUsageCallback';
let quota = 4054614016;
Utils.registerEvent("testGetOriginQuotaPromise", quota.toString(), 7178, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_2300
*tc.name testGetOriginUsageCallback
*tc.desc test api getOriginUsage callbcak mode by load loacal html
*/
it('testGetOriginUsageCallback', 0, async function(done){
emitKey = 'emitGetOriginUsagePromise';
let usage = 24576;
Utils.registerEvent("testGetOriginUsageCallback", usage, 7180, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_GETORIGINS_2400
*tc.name testGetOriginUsagePromise
*tc.desc test api getOriginUsage callbcak mode by load loacal html
*/
it('testGetOriginUsagePromise', 0, async function(done){
emitKey = 'emitGetOriginsDomStorageAccessFalse';
let usage = 24576;
Utils.registerEvent("testGetOriginUsagePromise", usage, 7182, done);
sendEventByKey('webStorage',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_0900
*tc.name testGetOriginsDomStorageAccessFalse
*tc.desc test api blockNetWork set to false by load online website
*/
it('testGetOriginsDomStorageAccessFalse',0,async function(done){
let quota = 4054614016;
Utils.registerEvent("testGetOriginsDomStorageAccessFalse", quota.toString(), 7184, done);
sendEventByKey('webStorage', 10, '');
})
})
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
eaaee736
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
"MainAbility/pages/onErrorReceive03"
,
"MainAbility/pages/onErrorReceive03"
,
"MainAbility/pages/webViewHasImage"
,
"MainAbility/pages/webViewHasImage"
,
"MainAbility/pages/webViewScrollTo"
,
"MainAbility/pages/webViewScrollTo"
,
"MainAbility/pages/webViewScrollBy"
"MainAbility/pages/webViewScrollBy"
,
"MainAbility/pages/webStorage"
]
]
}
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/getOrigins.html
0 → 100644
浏览文件 @
eaaee736
<!DOCTYPE HTML>
<html>
<head>
<meta
charset=
"UTF-8"
>
<script
type=
"text/javascript"
>
var
db
=
openDatabase
(
'
mydb
'
,
'
1.0
'
,
'
Test DB
'
,
2
*
1024
*
1024
);
var
msg
;
db
.
transaction
(
function
(
tx
)
{
tx
.
executeSql
(
'
CREATE TABLE IF NOT EXISTS LOGS (id unique, log)
'
);
tx
.
executeSql
(
'
INSERT INTO LOGS (id, log) VALUES (1, "W3Cschool教程")
'
);
tx
.
executeSql
(
'
INSERT INTO LOGS (id, log) VALUES (2, "www.w3cschool.cn")
'
);
msg
=
'
<p>数据表已创建,且插入了两条数据。</p>
'
;
document
.
querySelector
(
'
#status
'
).
innerHTML
=
msg
;
});
db
.
transaction
(
function
(
tx
)
{
tx
.
executeSql
(
'
SELECT * FROM LOGS
'
,
[],
function
(
tx
,
results
)
{
var
len
=
results
.
rows
.
length
,
i
;
msg
=
"
<p>查询记录条数:
"
+
len
+
"
</p>
"
;
document
.
querySelector
(
'
#status
'
).
innerHTML
+=
msg
;
for
(
i
=
0
;
i
<
len
;
i
++
){
msg
=
"
<p><b>
"
+
results
.
rows
.
item
(
i
).
log
+
"
</b></p>
"
;
document
.
querySelector
(
'
#status
'
).
innerHTML
+=
msg
;
}
},
null
);
});
</script>
</head>
<body>
<div
id=
"status"
name=
"status"
>
状态信息
</div>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录