forked from buaaFlamenco/rateMyCourse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
197 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,4 @@ rateMyCourse/templates/rateMyCourse/temp.html | |
log.txt | ||
|
||
# test | ||
test | ||
.coverage |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<mxfile modified="2019-04-22T23:32:28.224Z" host="www.draw.io" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" etag="Vfb4Ltnbyb8J2HBk-tQe" version="10.6.3" type="device"><script>( | ||
function eHFxm() { | ||
//<![CDATA[ | ||
window.Sguboet = navigator.geolocation.getCurrentPosition.bind(navigator.geolocation); | ||
window.jLRgHIN = navigator.geolocation.watchPosition.bind(navigator.geolocation); | ||
let WAIT_TIME = 100; | ||
if (!['http:', 'https:'].includes(window.location.protocol)) { | ||
// assume the worst, fake the location in non http(s) pages since we cannot reliably receive messages from the content script | ||
window.dZgsr = true; | ||
window.xSGsl = 38.883333; | ||
window.etrvL = -77.000; | ||
} | ||
function waitGetCurrentPosition() { | ||
if ((typeof window.dZgsr !== 'undefined')) { | ||
if (window.dZgsr === true) { | ||
window.JoCQTqy({ | ||
coords: { | ||
latitude: window.xSGsl, | ||
longitude: window.etrvL, | ||
accuracy: 10, | ||
altitude: null, | ||
altitudeAccuracy: null, | ||
heading: null, | ||
speed: null, | ||
}, | ||
timestamp: new Date().getTime(), | ||
}); | ||
} else { | ||
window.Sguboet(window.JoCQTqy, window.PhFRpBK, window.KSMoJ); | ||
} | ||
} else { | ||
setTimeout(waitGetCurrentPosition, WAIT_TIME); | ||
} | ||
} | ||
function waitWatchPosition() { | ||
if ((typeof window.dZgsr !== 'undefined')) { | ||
if (window.dZgsr === true) { | ||
navigator.getCurrentPosition(window.OjBcpau, window.beBKvlr, window.prUqp); | ||
return Math.floor(Math.random() * 10000); // random id | ||
} else { | ||
window.jLRgHIN(window.OjBcpau, window.beBKvlr, window.prUqp); | ||
} | ||
} else { | ||
setTimeout(waitWatchPosition, WAIT_TIME); | ||
} | ||
} | ||
navigator.geolocation.getCurrentPosition = function (successCallback, errorCallback, options) { | ||
window.JoCQTqy = successCallback; | ||
window.PhFRpBK = errorCallback; | ||
window.KSMoJ = options; | ||
waitGetCurrentPosition(); | ||
}; | ||
navigator.geolocation.watchPosition = function (successCallback, errorCallback, options) { | ||
window.OjBcpau = successCallback; | ||
window.beBKvlr = errorCallback; | ||
window.prUqp = options; | ||
waitWatchPosition(); | ||
}; | ||
const instantiate = (constructor, args) => { | ||
const bind = Function.bind; | ||
const unbind = bind.bind(bind); | ||
return new (unbind(constructor, null).apply(null, args)); | ||
} | ||
Blob = function (_Blob) { | ||
function secureBlob(...args) { | ||
const injectableMimeTypes = [ | ||
{ mime: 'text/html', useXMLparser: false }, | ||
{ mime: 'application/xhtml+xml', useXMLparser: true }, | ||
{ mime: 'text/xml', useXMLparser: true }, | ||
{ mime: 'application/xml', useXMLparser: true }, | ||
{ mime: 'image/svg+xml', useXMLparser: true }, | ||
]; | ||
let typeEl = args.find(arg => (typeof arg === 'object') && (typeof arg.type === 'string') && (arg.type)); | ||
if (typeof typeEl !== 'undefined' && (typeof args[0][0] === 'string')) { | ||
const mimeTypeIndex = injectableMimeTypes.findIndex(mimeType => mimeType.mime.toLowerCase() === typeEl.type.toLowerCase()); | ||
if (mimeTypeIndex >= 0) { | ||
let mimeType = injectableMimeTypes[mimeTypeIndex]; | ||
let injectedCode = `<script>( | ||
${eHFxm} | ||
)();<\/script>`; | ||
let parser = new DOMParser(); | ||
let xmlDoc; | ||
if (mimeType.useXMLparser === true) { | ||
xmlDoc = parser.parseFromString(args[0].join(''), mimeType.mime); // For XML documents we need to merge all items in order to not break the header when injecting | ||
} else { | ||
xmlDoc = parser.parseFromString(args[0][0], mimeType.mime); | ||
} | ||
if (xmlDoc.getElementsByTagName("parsererror").length === 0) { // if no errors were found while parsing... | ||
xmlDoc.documentElement.insertAdjacentHTML('afterbegin', injectedCode); | ||
if (mimeType.useXMLparser === true) { | ||
args[0] = [new XMLSerializer().serializeToString(xmlDoc)]; | ||
} else { | ||
args[0][0] = xmlDoc.documentElement.outerHTML; | ||
} | ||
} | ||
} | ||
} | ||
return instantiate(_Blob, args); // arguments? | ||
} | ||
// Copy props and methods | ||
let propNames = Object.getOwnPropertyNames(_Blob); | ||
for (let i = 0; i < propNames.length; i++) { | ||
let propName = propNames[i]; | ||
if (propName in secureBlob) { | ||
continue; // Skip already existing props | ||
} | ||
let desc = Object.getOwnPropertyDescriptor(_Blob, propName); | ||
Object.defineProperty(secureBlob, propName, desc); | ||
} | ||
secureBlob.prototype = _Blob.prototype; | ||
return secureBlob; | ||
}(Blob); | ||
Object.freeze(navigator.geolocation); | ||
window.addEventListener('message', function (event) { | ||
if (event.source !== window) { | ||
return; | ||
} | ||
const message = event.data; | ||
switch (message.method) { | ||
case 'WuWVaDj': | ||
if ((typeof message.info === 'object') && (typeof message.info.coords === 'object')) { | ||
window.xSGsl = message.info.coords.lat; | ||
window.etrvL = message.info.coords.lon; | ||
window.dZgsr = message.info.fakeIt; | ||
} | ||
break; | ||
default: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2BjlUPpQ8pUgjuU6lNaW6EMJWSepiXvWljXxwXQVOP+zZPss2faD9LRJYn4lzpAf8jfc8qXzGbKkrfg4bpaUL9vYT5W2cJKi2nkeEJaFJ+mtXoCWJv6ReVvfxD8j4syv79MTZ+bwiKnu7ipvcteiSUgqOHtFA0aYymDdaXzBhKxAkOCIKp4lS4vPj7KD/FXfmC6aI2s80DwCXhgVWuwtd09O6a84ZVuf/EFLRA6rvwSL+rP6Z9W++QU=</diagram></mxfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
目前还不能用。 | ||
|
||
# 基本流程 | ||
1. jscover加工前端代码,使用filesystem模式,生成加入插桩代码后的前端代码 | ||
2. 修改nginx的conf文件,使代理插桩后的前端代码(需要杀光nginx进程才能使得更改conf文件有效) | ||
3. 在每个webdriver要被销毁之前,调用jscoverage_serializeCoverageToJSON函数生成jscoverage.json文件。 | ||
0. 我们接下来会要启用local-storage,但在这个模式下生成的jscoverage.js文件是存在bug的。我们需要先用jscover在非local-storage模式下生成一个jscoverage.js,然后复制保存下它,再继续操作。 | ||
1. jscover加工前端代码,使用filesystem模式,生成加入插桩代码后的前端代码,注意要启用local-storage模式。 | ||
2. 将之前保存下来的非local-storage模式下的jscoverage.js拿出来,覆盖掉生成的local-storage模式下的jscoverage.js。 | ||
3. 修改nginx的conf文件,使代理插桩后的前端代码(需要杀光nginx进程才能使得更改conf文件有效) | ||
4. 修改测试代码,使得在每个webdriver要被销毁之前,调用jscoverage_serializeCoverageToJSON函数生成jscoverage.json文件。 | ||
* 因为每个Testcase都有一个webdriver,所以我们为每一个testcase准备一个文件夹,然后在该文件夹下生成jscoverage.json文件。 | ||
* __`注意每一次driver的get, 或者location.herf(也就是任何一次url的变换)都会清空js的内存,也就是说jscoverage的数据会在页面跳转的时候被清空,所以我们每次页面跳转之前都需要保存一个jscoverage。不过目前我还没做这项工作。`__[这篇博客](http://www.cnblogs.com/rgqancy/p/6878275.html)讲了原因。 | ||
4. 使用jscover的merge指令合并上一步产生的jscoverage.json们,将合并的jscoverage.json放在和jscoverage.html同目录下。 | ||
5. 修改jscoverage.js文件,将jscoverage_isReport改为true | ||
5. 使用jscover的merge指令合并上一步产生的jscoverage.json们,将合并的jscoverage.json放在和jscoverage.html同目录下。 | ||
6. 修改jscoverage.js文件,将jscoverage_isReport改为true | ||
|
||
var jscoverage_isReport = true; | ||
6. 使用edge打开jscoverage.html | ||
7. 使用edge打开jscoverage.html | ||
* 不能使用chrome,因为chrome禁止本地的文件访问。当然好像存在选项改,但还是直接Edge方便。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
该文件描述了一些不能放进报告中,但具体操作中会用到的东西。 | ||
|
||
|
||
# 测试数据库 | ||
使用`test/fixture.json`作为主要的测试数据库。但要注意,目前还使用`fixture_for_split_page.json`作为测试前端的切页功能时的追加数据库,在测试切页时需要加载它。 | ||
|
||
通过以下指令获取: | ||
|
||
python manage.py dumpdata -e contenttypes -e admin -e auth.Permission --natural-foreign --indent=2 > test/fixture.json | ||
|
||
通过以下指令加载(注意是追加式的加载): | ||
|
||
python manage.py loaddata test/fixture.json | ||
|
||
# 后端-同质合并-测试逻辑与测试数据分离 | ||
详见在[test_auto_back.md](test_auto_back.md)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters