[go: up one dir, main page]

CN109634844B - JS code testing method and device and electronic equipment - Google Patents

JS code testing method and device and electronic equipment Download PDF

Info

Publication number
CN109634844B
CN109634844B CN201811317347.3A CN201811317347A CN109634844B CN 109634844 B CN109634844 B CN 109634844B CN 201811317347 A CN201811317347 A CN 201811317347A CN 109634844 B CN109634844 B CN 109634844B
Authority
CN
China
Prior art keywords
function
code
compatibility
tested
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811317347.3A
Other languages
Chinese (zh)
Other versions
CN109634844A (en
Inventor
焦玉琨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
360 Technology Group Co Ltd
Original Assignee
360 Technology Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 360 Technology Group Co Ltd filed Critical 360 Technology Group Co Ltd
Priority to CN201811317347.3A priority Critical patent/CN109634844B/en
Publication of CN109634844A publication Critical patent/CN109634844A/en
Application granted granted Critical
Publication of CN109634844B publication Critical patent/CN109634844B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the technical field of Internet, in particular to a JS code testing method and device and electronic equipment. The JS code testing method comprises the following steps: acquiring a JS code to be tested and a first configuration file corresponding to the JS code to be tested; and simultaneously testing the compatibility of the JS codes to be tested relative to a preset browser set based on the first configuration file, and obtaining a code compatibility test result of the JS codes to be tested. When the JS code to be tested is required to be tested, the compatibility of the JS code to be tested relative to a preset browser set can be directly and simultaneously tested only on the basis of the first configuration file, so that a code compatibility test result of the JS code to be tested is obtained, and compared with the scheme that each browser is used for testing the compatibility of the JS code to be tested in a manual test mode in the prior art, the test efficiency is improved to a greater extent.

Description

JS代码测试方法、装置及电子设备JS code testing methods, devices and electronic equipment

技术领域Technical field

本发明涉及互联网技术领域,具体而言,涉及一种JS代码测试方法、装置及电子设备。The present invention relates to the field of Internet technology, and specifically to a JS code testing method, device and electronic equipment.

背景技术Background technique

JS即Javascript,是为了适应动态网页制作的需要而诞生的一种编程语言,如今越来越广泛地应用于Intemet网页的制作上,因此,JS代码的开发量和测试量也在逐渐增大。但现有技术中,JS代码的测试效率较低,例如,在测试预设浏览器集合对待测试JS代码的兼容性时,只能通过人工测试的方式分别测试每个预设浏览器对待测试JS代码的兼容性,因此,测试效率极低。JS, or Javascript, is a programming language born to meet the needs of dynamic web page production. It is now more and more widely used in the production of Internet web pages. Therefore, the amount of development and testing of JS code is also gradually increasing. However, in the existing technology, the testing efficiency of JS code is low. For example, when testing the compatibility of the JS code to be tested in a set of preset browsers, each preset browser to be tested JS code can only be tested separately through manual testing. Code compatibility, therefore, testing efficiency is extremely low.

发明内容Contents of the invention

有鉴于此,本发明实施例的目的在于提供一种JS代码测试方法、装置及电子设备,以有效改善上述问题。In view of this, the purpose of embodiments of the present invention is to provide a JS code testing method, device and electronic equipment to effectively improve the above problems.

本发明实施例中提供的JS代码测试方法,包括:The JS code testing method provided in the embodiment of the present invention includes:

获取待测试JS代码,以及与所述待测试JS代码对应的第一配置文件;Obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested;

基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果。Based on the first configuration file, the compatibility of the JS code to be tested with respect to a preset browser set is simultaneously tested to obtain a code compatibility test result of the JS code to be tested.

进一步地,所述待测试JS代码中包括至少一个目标JS函数,所述第一配置文件中包括至少一条用于表征JS函数相对于所述预设浏览器集合不兼容的函数兼容性信息;Further, the JS code to be tested includes at least one target JS function, and the first configuration file includes at least one piece of function compatibility information used to indicate that the JS function is incompatible with the preset browser set;

所述基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果,包括:Simultaneously testing the compatibility of the JS code to be tested with respect to a preset browser set based on the first configuration file and obtaining the code compatibility test results of the JS code to be tested includes:

基于至少一条所述函数兼容性信息,分别确定所述待测试JS代码中的各个目标JS函数相对于所述预设浏览器集合的函数兼容性测试结果;Based on at least one piece of the function compatibility information, respectively determine the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set;

根据所述待测试JS代码中的所有目标JS函数的函数兼容性测试结果,确定所述待测试JS代码的代码兼容性测试结果;Determine the code compatibility test results of the JS code to be tested based on the function compatibility test results of all target JS functions in the JS code to be tested;

其中,若所述待测试JS代码中的所有目标JS函数均相对于所述预设浏览器集合兼容,则将所述待测试JS代码的代码兼容性测试结果确定为兼容,否则,将所述待测试JS代码的代码兼容性测试结果确定为不兼容。Wherein, if all target JS functions in the JS code to be tested are compatible with the preset browser set, the code compatibility test result of the JS code to be tested is determined to be compatible; otherwise, the code compatibility test result of the JS code to be tested is determined to be compatible. The code compatibility test result of the JS code to be tested is determined to be incompatible.

进一步地,所述基于至少一条所述函数兼容性信息,分别确定所述待测试JS代码中的各个目标JS函数相对于所述预设浏览器集合的函数兼容性测试结果,包括:Further, based on at least one piece of the function compatibility information, respectively determining the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set includes:

针对所述待测试JS代码中的每个目标JS函数,分别判断所述第一配置文件中是否存在与所述目标JS函数对应的函数兼容性信息;For each target JS function in the JS code to be tested, determine whether there is function compatibility information corresponding to the target JS function in the first configuration file;

若所述第一配置文件中存在与所述目标JS函数对应的函数兼容性信息,则根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,否则,将所述目标JS函数的函数兼容性测试结果确定为兼容。If there is function compatibility information corresponding to the target JS function in the first configuration file, the function compatibility test result of the target JS function is determined according to the function compatibility information; otherwise, the function compatibility test result of the target JS function is determined. The function compatibility test result of the target JS function is determined to be compatible.

进一步地,所述函数兼容性信息包括函数标签和与所述函数标签对应的函数内容,每个所述函数标签对应一JS函数,所述函数内容用于表征与所述函数标签对应的JS函数相对于所述预设浏览器集合中的浏览器的兼容性;Further, the function compatibility information includes function labels and function content corresponding to the function labels. Each function label corresponds to a JS function, and the function content is used to characterize the JS function corresponding to the function label. Compatibility relative to the browsers in the preset browser set;

所述根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,包括:Determining the function compatibility test result of the target JS function based on the function compatibility information includes:

基于预设信息关联情况,确定所述函数兼容性信息的关联类型,所述关联类型包括第一关联类型和第二关联类型,所述第一关联类型用于表征在所述第一配置文件中不存在与所述函数兼容信息功能关联的函数兼容性信息,所述第二关联类型用于表征在所述第一配置文件中存在与所述函数兼容信息功能关联的函数兼容性信息;Based on the preset information association situation, the association type of the function compatibility information is determined. The association type includes a first association type and a second association type. The first association type is used to characterize the information in the first configuration file. There is no function compatibility information functionally associated with the function compatibility information, and the second association type is used to represent that there is function compatibility information functionally associated with the function compatibility information in the first configuration file;

若所述函数兼容信息的关联类型为所述第一关联类型,则根据所述函数兼容信息,确定所述目标JS函数的所述函数兼容性测试结果;If the association type of the function compatibility information is the first association type, determine the function compatibility test result of the target JS function according to the function compatibility information;

若所述函数兼容信息的关联类型为所述第二关联类型,则根据所述函数兼容信息的函数内容以及与所述函数兼容信息功能关联的函数兼容性信息的函数内容,确定所述目标JS函数的所述函数兼容性测试结果。If the association type of the function compatibility information is the second association type, the target JS is determined based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information. The function compatibility test results for the function.

进一步地,所述根据所述函数兼容信息的函数内容以及与所述函数兼容信息功能关联的函数兼容性信息的函数内容,确定所述目标JS函数的所述函数兼容性测试结果,包括:Further, determining the function compatibility test result of the target JS function based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information includes:

根据所述函数兼容信息的函数内容,获得对与所述函数兼容信息对应的JS函数兼容的浏览器,作为第一浏览器;According to the function content of the function compatibility information, a browser compatible with the JS function corresponding to the function compatibility information is obtained as the first browser;

将与所述函数兼容信息功能关联的函数兼容性信息,作为关联函数兼容性信息,并根据所述关联函数兼容性信息的函数内容,获得对与所述关联函数兼容信息对应的JS函数兼容的浏览器,作为第二浏览器;The function compatibility information functionally associated with the function compatibility information is used as the associated function compatibility information, and based on the function content of the associated function compatibility information, a function compatible with the JS function corresponding to the associated function compatibility information is obtained. Browser, as a second browser;

判断所述第一浏览器与所述第二浏览器的集合是否与所述预设浏览器集合相同;Determine whether the set of the first browser and the second browser is the same as the default browser set;

若所述第一浏览器与所述第二浏览器的集合与所述预设浏览器集合相同,则确定所述目标JS函数的所述函数兼容性测试结果为兼容,否则,确定所述目标JS函数的所述函数兼容性测试结果为不兼容。If the set of the first browser and the second browser is the same as the preset browser set, it is determined that the function compatibility test result of the target JS function is compatible; otherwise, it is determined that the target JS function is compatible. The function compatibility test result of the JS function is incompatible.

进一步地,当所述目标JS函数的所述函数兼容性测试结果为不兼容时,所述根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,还包括:Further, when the function compatibility test result of the target JS function is incompatible, determining the function compatibility test result of the target JS function according to the function compatibility information further includes:

基于预设浏览器兼容性情况,确定所述函数兼容性信息的不兼容类型,所述不兼容类型包括第一不兼容类型和第二不兼容类型,所述第一不兼容类型用于表征所述函数兼容性信息的不兼容情况为完全不兼容,所述第二不兼容类型用于表征所述函数兼容性信息的不兼容情况为不完全兼容;Based on the preset browser compatibility situation, the incompatibility type of the function compatibility information is determined. The incompatibility type includes a first incompatibility type and a second incompatibility type. The first incompatibility type is used to characterize the The incompatibility of the function compatibility information is completely incompatible, and the second incompatibility type is used to characterize the incompatibility of the function compatibility information as incomplete compatibility;

若所述函数兼容性信息的不兼容类型为所述第一不兼容类型,则将所述目标JS函数的函数兼容性结果确定为完全不兼容;If the incompatibility type of the function compatibility information is the first incompatibility type, determine the function compatibility result of the target JS function to be completely incompatible;

若所述函数兼容性信息的不兼容类型为所述第二不兼容类型,则所述目标JS函数的函数兼容性结果确定为不完全兼容。If the incompatibility type of the function compatibility information is the second incompatibility type, the function compatibility result of the target JS function is determined to be incompletely compatible.

进一步地,所述JS代码测试方法,还包括:Further, the JS code testing method also includes:

获取所述待测试JS代码对应的第二配置文件;Obtain the second configuration file corresponding to the JS code to be tested;

基于所述第二配置文件测试所述待测试JS代码的语法规范性,获得所述待测试JS代码的代码语法规范性测试结果。The syntax standardization of the JS code to be tested is tested based on the second configuration file, and the code syntax standardization test result of the JS code to be tested is obtained.

进一步地,所述第二配置文件中包括至少一条用于表征待测试JS代码具有的语法不规范问题的语法规范性信息;Further, the second configuration file includes at least one piece of grammatical normative information used to characterize the grammatical irregularities of the JS code to be tested;

所述基于所述第二配置文件测试所述待测试JS代码的语法规范性,获得所述待测试JS代码的代码语法规范性测试结果,包括:The method of testing the syntax standardization of the JS code to be tested based on the second configuration file and obtaining the code syntax standardization test results of the JS code to be tested includes:

针对每条所述语法规范性信息,判断所述待测试JS代码中是否存在与所述语法规范性信息对应的语法设置;For each piece of grammatical normative information, determine whether there is a grammatical setting corresponding to the grammatical normative information in the JS code to be tested;

若所述待测试JS代码中存在与所述语法规范性信息对应的语法设置,则将所述语法设置作为不规范语法;If there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is regarded as non-standard grammar;

若所述JS代码中存在所述不规范语法,则确定所述待测试JS代码的代码语法规范性测试结果为不规范,否则,确定所述待测试JS代码的代码语法规范性测试结果为规范。If the non-standard syntax exists in the JS code, it is determined that the code syntax normative test result of the JS code to be tested is non-standard; otherwise, it is determined that the code syntax normative test result of the JS code to be tested is normative. .

进一步地,若所述待测试JS代码中存在与所述语法规范性信息对应的语法设置,则将所述语法设置作为不规范语法,包括:Further, if there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is regarded as non-standard grammar, including:

基于预设语法规范性情况,确定所述语法规范性信息的不规范类型,所述不规范类型包括第一不规范类型和第二不规范类型,所述第一不规范类型用于表征所述语法规范性信息的语法不规范问题为完全不规范,所述第二不规范类型用于表征所述语法规范性信息的不规范问题为不完全规范;Based on the preset grammatical normative situation, the irregularity type of the grammatical normative information is determined. The irregularity type includes a first irregularity type and a second irregularity type. The first irregularity type is used to characterize the The grammatical irregularities of the grammatical normative information are completely irregular, and the second irregularity type used to characterize the irregularities of the grammatical normative information is incompletely normative;

若所述语法规范性信息的不规范类型为所述第一不规范类型,则将所述语法设置作为完全不规范语法;If the irregularity type of the grammar normative information is the first irregularity type, then the grammar is set as a completely irregular grammar;

若所述语法规范性信息的不规范类型为所述第二不规范类型,则将所述语法设置作为完全不完全规范语法。If the irregularity type of the grammar normative information is the second irregularity type, the grammar is set as a completely incomplete normative grammar.

本发明实施例提供的JS代码测试装置,包括:The JS code testing device provided by the embodiment of the present invention includes:

第一配置文件获取模块,用于获取待测试JS代码,以及与所述待测试JS代码对应的第一配置文件;The first configuration file acquisition module is used to obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested;

第一测试结果获取模块,用于基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果。The first test result acquisition module is configured to simultaneously test the compatibility of the JS code to be tested with respect to the preset browser collection based on the first configuration file, and obtain the code compatibility test results of the JS code to be tested.

进一步地所述待测试JS代码中包括至少一个目标JS函数,所述第一配置文件中包括至少一条用于表征JS函数相对于所述预设浏览器集合不兼容的函数兼容性信息;Further, the JS code to be tested includes at least one target JS function, and the first configuration file includes at least one piece of function compatibility information used to indicate that the JS function is incompatible with the preset browser set;

所述第一测试结果获取模块,具体用于:The first test result acquisition module is specifically used for:

基于至少一条所述函数兼容性信息,分别确定所述待测试JS代码中的各个目标JS函数相对于所述预设浏览器集合的函数兼容性测试结果;Based on at least one piece of the function compatibility information, respectively determine the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set;

根据所述待测试JS代码中的所有目标JS函数的函数兼容性测试结果,确定所述待测试JS代码的代码兼容性测试结果;Determine the code compatibility test results of the JS code to be tested based on the function compatibility test results of all target JS functions in the JS code to be tested;

其中,若所述待测试JS代码中的所有目标JS函数均相对于所述预设浏览器集合兼容,则将所述待测试JS代码的代码兼容性测试结果确定为兼容,否则,将所述待测试JS代码的代码兼容性测试结果确定为不兼容。Wherein, if all target JS functions in the JS code to be tested are compatible with the preset browser set, the code compatibility test result of the JS code to be tested is determined to be compatible; otherwise, the code compatibility test result of the JS code to be tested is determined to be compatible. The code compatibility test result of the JS code to be tested is determined to be incompatible.

进一步地所述第一测试结果获取模块,又具体用于:Further, the first test result acquisition module is specifically used for:

针对所述待测试JS代码中的每个目标JS函数,分别判断所述第一配置文件中是否存在与所述目标JS函数对应的函数兼容性信息;For each target JS function in the JS code to be tested, determine whether there is function compatibility information corresponding to the target JS function in the first configuration file;

若所述第一配置文件中存在与所述目标JS函数对应的函数兼容性信息,则根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,否则,将所述目标JS函数的函数兼容性测试结果确定为兼容。If there is function compatibility information corresponding to the target JS function in the first configuration file, the function compatibility test result of the target JS function is determined according to the function compatibility information; otherwise, the function compatibility test result of the target JS function is determined. The function compatibility test result of the target JS function is determined to be compatible.

进一步地所述函数兼容性信息包括函数标签和与所述函数标签对应的函数内容,每个所述函数标签对应一JS函数,所述函数内容用于表征与所述函数标签对应的JS函数相对于所述预设浏览器集合中的浏览器的兼容性;Further, the function compatibility information includes function labels and function content corresponding to the function labels. Each function label corresponds to a JS function, and the function content is used to represent the relative relationship between the JS functions corresponding to the function labels. Compatibility of browsers in the default browser set;

所述第一测试结果获取模块,又具体用于:The first test result acquisition module is specifically used for:

基于预设信息关联情况,确定所述函数兼容性信息的关联类型,所述关联类型包括第一关联类型和第二关联类型,所述第一关联类型用于表征在所述第一配置文件中不存在与所述函数兼容信息功能关联的函数兼容性信息,所述第二关联类型用于表征在所述第一配置文件中存在与所述函数兼容信息功能关联的函数兼容性信息;Based on the preset information association situation, the association type of the function compatibility information is determined. The association type includes a first association type and a second association type. The first association type is used to characterize the information in the first configuration file. There is no function compatibility information functionally associated with the function compatibility information, and the second association type is used to represent that there is function compatibility information functionally associated with the function compatibility information in the first configuration file;

若所述函数兼容信息的关联类型为所述第一关联类型,则根据所述函数兼容信息,确定所述目标JS函数的所述函数兼容性测试结果;If the association type of the function compatibility information is the first association type, determine the function compatibility test result of the target JS function according to the function compatibility information;

若所述函数兼容信息的关联类型为所述第二关联类型,则根据所述函数兼容信息的函数内容以及与所述函数兼容信息功能关联的函数兼容性信息的函数内容,确定所述目标JS函数的所述函数兼容性测试结果。If the association type of the function compatibility information is the second association type, the target JS is determined based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information. The function compatibility test results for the function.

进一步地所述第一测试结果获取模块,又具体用于:Further, the first test result acquisition module is specifically used for:

根据所述函数兼容信息的函数内容,获得对与所述函数兼容信息对应的JS函数兼容的浏览器,作为第一浏览器;According to the function content of the function compatibility information, a browser compatible with the JS function corresponding to the function compatibility information is obtained as the first browser;

将与所述函数兼容信息功能关联的函数兼容性信息,作为关联函数兼容性信息,并根据所述关联函数兼容性信息的函数内容,获得对与所述关联函数兼容信息对应的JS函数兼容的浏览器,作为第二浏览器;The function compatibility information functionally associated with the function compatibility information is used as the associated function compatibility information, and based on the function content of the associated function compatibility information, a function compatible with the JS function corresponding to the associated function compatibility information is obtained. Browser, as a second browser;

判断所述第一浏览器与所述第二浏览器的集合是否与所述预设浏览器集合相同;Determine whether the set of the first browser and the second browser is the same as the default browser set;

若所述第一浏览器与所述第二浏览器的集合与所述预设浏览器集合相同,则确定所述目标JS函数的所述函数兼容性测试结果为兼容,否则,确定所述目标JS函数的所述函数兼容性测试结果为不兼容。If the set of the first browser and the second browser is the same as the preset browser set, it is determined that the function compatibility test result of the target JS function is compatible; otherwise, it is determined that the target JS function is compatible. The function compatibility test result of the JS function is incompatible.

进一步地当所述目标JS函数的所述函数兼容性测试结果为不兼容时,所述第一测试结果获取模块,还具体用于:Further, when the function compatibility test result of the target JS function is incompatible, the first test result acquisition module is also specifically used to:

基于预设浏览器兼容性情况,确定所述函数兼容性信息的不兼容类型,所述不兼容类型包括第一不兼容类型和第二不兼容类型,所述第一不兼容类型用于表征所述函数兼容性信息的不兼容情况为完全不兼容,所述第二不兼容类型用于表征所述函数兼容性信息的不兼容情况为不完全兼容;Based on the preset browser compatibility situation, the incompatibility type of the function compatibility information is determined. The incompatibility type includes a first incompatibility type and a second incompatibility type. The first incompatibility type is used to characterize the The incompatibility of the function compatibility information is completely incompatible, and the second incompatibility type is used to characterize the incompatibility of the function compatibility information as incomplete compatibility;

若所述函数兼容性信息的不兼容类型为所述第一不兼容类型,则将所述目标JS函数的函数兼容性结果确定为完全不兼容;If the incompatibility type of the function compatibility information is the first incompatibility type, determine the function compatibility result of the target JS function to be completely incompatible;

若所述函数兼容性信息的不兼容类型为所述第二不兼容类型,则所述目标JS函数的函数兼容性结果确定为不完全兼容。If the incompatibility type of the function compatibility information is the second incompatibility type, the function compatibility result of the target JS function is determined to be incompletely compatible.

进一步地所述JS代码测试装置,还包括:Further, the JS code testing device also includes:

第二配置文件获取模块,用于获取所述待测试JS代码对应的第二配置文件;The second configuration file acquisition module is used to obtain the second configuration file corresponding to the JS code to be tested;

第二测试结果获取模块,用于基于所述第二配置文件测试所述待测试JS代码的语法规范性,获得所述待测试JS代码的代码语法规范性测试结果。The second test result acquisition module is configured to test the syntax standardization of the JS code to be tested based on the second configuration file, and obtain the code syntax standardization test results of the JS code to be tested.

进一步地所述第二配置文件中包括至少一条用于表征待测试JS代码具有的语法不规范问题的语法规范性信息;Further, the second configuration file includes at least one piece of grammatical normative information used to characterize the grammatical irregularities of the JS code to be tested;

所述第二测试结果获取模块,具体用于:The second test result acquisition module is specifically used for:

针对每条所述语法规范性信息,判断所述待测试JS代码中是否存在与所述语法规范性信息对应的语法设置;For each piece of grammatical normative information, determine whether there is a grammatical setting corresponding to the grammatical normative information in the JS code to be tested;

若所述待测试JS代码中存在与所述语法规范性信息对应的语法设置,则将所述语法设置作为不规范语法;If there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is regarded as non-standard grammar;

若所述JS代码中存在所述不规范语法,则确定所述待测试JS代码的代码语法规范性测试结果为不规范,否则,确定所述待测试JS代码的代码语法规范性测试结果为规范。If the non-standard syntax exists in the JS code, it is determined that the code syntax normative test result of the JS code to be tested is non-standard; otherwise, it is determined that the code syntax normative test result of the JS code to be tested is normative. .

进一步地所述第二测试结果获取模块,又具体用于:基于预设语法规范性情况,确定所述语法规范性信息的不规范类型,所述不规范类型包括第一不规范类型和第二不规范类型,所述第一不规范类型用于表征所述语法规范性信息的语法不规范问题为完全不规范,所述第二不规范类型用于表征所述语法规范性信息的不规范问题为不完全规范;Further, the second test result acquisition module is specifically configured to determine the irregularity type of the grammatical normative information based on the preset grammatical normative situation. The irregularity type includes a first irregularity type and a second irregularity type. Irregularity type, the first irregularity type is used to characterize the grammatical irregularity of the grammatical normative information as completely irregular, and the second irregularity type is used to characterize the irregularity of the grammatical normative information. For incomplete specification;

若所述语法规范性信息的不规范类型为所述第一不规范类型,则将所述语法设置作为完全不规范语法;If the irregularity type of the grammar normative information is the first irregularity type, then the grammar is set as a completely irregular grammar;

若所述语法规范性信息的不规范类型为所述第二不规范类型,则将所述语法设置作为完全不完全规范语法。If the irregularity type of the grammar normative information is the second irregularity type, the grammar is set as a completely incomplete normative grammar.

本发明实施例提供的电子设备,包括处理器、存储器和上述JS代码测试装置,所述JS代码测试装置包括一个或多个存储于所述存储器并由所述处理器执行的软件功能模块。An electronic device provided by an embodiment of the present invention includes a processor, a memory, and the above JS code testing device. The JS code testing device includes one or more software function modules stored in the memory and executed by the processor.

本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被执行时,可以实现上述JS代码测试方法。Embodiments of the present invention also provide a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the above JS code testing method can be implemented.

本发明实施例提供的JS代码测试方法、装置及电子设备能够获取待测试JS代码,以及与所述待测试JS代码对应的第一配置文件,并基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果。如此,在需要对待测试JS代码进行测试时,只需基于第一配置文件就可以直接同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,从而获得待测试JS代码的代码兼容性测试结果,因此,相较于现有技术中,通过人工测试的方式分别测试每个浏览器对待测试JS代码的兼容性的方案而言,测试效率有了较大程度的提高。The JS code testing method, device and electronic equipment provided by the embodiments of the present invention can obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested, and simultaneously test the JS code to be tested based on the first configuration file. Test the compatibility of the JS code with respect to the preset browser set, and obtain the code compatibility test results of the JS code to be tested. In this way, when the JS code to be tested needs to be tested, the compatibility of the JS code to be tested with respect to the preset browser collection can be directly and simultaneously tested based on the first configuration file, thereby obtaining code compatibility of the JS code to be tested. Therefore, compared with the existing technology, which uses manual testing to separately test the compatibility of each browser with the JS code to be tested, the testing efficiency has been greatly improved.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solution of the present invention. In order to have a clearer understanding of the technical means of the present invention, it can be implemented according to the content of the description, and in order to make the above and other objects, features and advantages of the present invention more obvious and understandable. , the specific embodiments of the present invention are listed below.

附图说明Description of the drawings

为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present disclosure and therefore do not It should be regarded as a limitation of the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without exerting creative efforts.

图1为本发明实施例提供的电子设备的示意性结构框图。Figure 1 is a schematic structural block diagram of an electronic device provided by an embodiment of the present invention.

图2为本发明实施例提供的一种JS代码测试方法的流程示意图。Figure 2 is a schematic flow chart of a JS code testing method provided by an embodiment of the present invention.

图3为本发明实施例提供的一种JS代码测试方法的另一部分流程示意图。Figure 3 is another partial flow chart of a JS code testing method provided by an embodiment of the present invention.

图4为本发明实施例提供的一种JS代码测试装置的示意性结构框图。Figure 4 is a schematic structural block diagram of a JS code testing device provided by an embodiment of the present invention.

图5为本发明实施例提供的一种JS代码测试装置的另一部分示意性结构框图。Figure 5 is another schematic structural block diagram of a JS code testing device provided by an embodiment of the present invention.

图标:100-电子设备;110-JS代码测试装置;111-第一配置文件获取模块;112-第一测试结果获取模块;113-第二配置文件获取模块;114-第二测试结果获取模块;120-处理器;130-存储器。Icons: 100-electronic equipment; 110-JS code testing device; 111-first configuration file acquisition module; 112-first test result acquisition module; 113-second configuration file acquisition module; 114-second test result acquisition module; 120-processor; 130-memory.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本发明实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the invention generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the disclosure provided in the appended drawings is not intended to limit the scope of the claimed disclosure, but rather to represent selected embodiments of the disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without any creative efforts shall fall within the scope of protection of the present disclosure.

应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that similar reference numerals and letters represent similar items in the following figures, therefore, once an item is defined in one figure, it does not need further definition and explanation in subsequent figures.

请参阅图1,为本发明实施例提供的一种应用JS代码测试方法及装置的电子设备100的示意性结构框图。进一步地,本发明实施例中,该电子设备100包括代码测试装置110、处理器120和存储器130。Please refer to FIG. 1 , which is a schematic structural block diagram of an electronic device 100 using a JS code testing method and device according to an embodiment of the present invention. Further, in the embodiment of the present invention, the electronic device 100 includes a code testing device 110, a processor 120 and a memory 130.

处理器120和存储器130之间直接或间接地电性连接,以实现数据的传输或交互,例如,这些元件相互之间可通过一条或多条通讯总线或信号线实现电性连接。JS代码测试装置110包括至少一个可以软件或固件(Firmware)的形式存储在存储器130中或固化在电子设备100的操作系统(Operating System,OS)中的软件模块。处理器120用于执行存储器130中存储的可执行模块,例如,JS代码测试装置110所包括的软件功能模块及计算机程序等。处理器120可以在接收到执行指令后,执行计算机程序。The processor 120 and the memory 130 are electrically connected directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The JS code testing device 110 includes at least one software module that can be stored in the memory 130 in the form of software or firmware or solidified in the operating system (Operating System, OS) of the electronic device 100 . The processor 120 is used to execute executable modules stored in the memory 130, such as software function modules and computer programs included in the JS code testing device 110. The processor 120 can execute the computer program after receiving the execution instruction.

其中,处理器120可以是一种集成电路芯片,具有信号处理能力。处理器120也可以是通用处理器,例如,可以是数字信号处理器(DSP)、专用集成电路(ASIC)、分立门或晶体管逻辑器件、分立硬件组件,可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。此外,通用处理器可以是微处理器或者任何常规处理器等。The processor 120 may be an integrated circuit chip with signal processing capabilities. The processor 120 may also be a general-purpose processor, for example, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the steps in the embodiments of the present invention. Disclosed methods, steps and logical block diagrams. Furthermore, the general-purpose processor may be a microprocessor or any conventional processor or the like.

存储器130可以是,但不限于,随机存取存储器(Random Access Memory,RAM),只读存储器(Read Only Memory,ROM),可编程只读存储器(Programmable Read-OnlyMemory,PROM),可擦可编程序只读存储器(Erasable Programmable Read-Only Memory,EPROM),电可擦编程只读存储器Electric Erasable Programmable Read-Only Memory,EEPROM)等。存储器130用于存储程序,处理器120在接收到执行指令后,执行该程序。The memory 130 may be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only Memory, PROM), erasable and programmable memory. Program read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable programmable read-only memory, Electric Erasable Programmable Read-Only Memory, EEPROM), etc. The memory 130 is used to store a program, and the processor 120 executes the program after receiving the execution instruction.

应当理解,图1所示的结构仅为示意,本发明实施例提供的电子设备100还可以具有比图1更少或更多的组件,或是具有与图1所示不同的配置。此外,图1所示的各组件可以通过软件、硬件或其组合实现。It should be understood that the structure shown in FIG. 1 is only illustrative, and the electronic device 100 provided by the embodiment of the present invention may also have fewer or more components than that shown in FIG. 1 , or have a different configuration than that shown in FIG. 1 . In addition, each component shown in Figure 1 can be implemented by software, hardware, or a combination thereof.

请参阅图2,图2为本发明实施例提供的JS代码测试方法的流程示意图,该JS代码测试方法应用于图1所示的电子设备,下面结合图2对该JS代码测试方法的具体流程及步骤进行详细阐述。所应说明的是,本发明提供的方法不以图2及以下所示的顺序为限制,以下结合图2对JS代码测试方法的具体流程及步骤进行详细阐述。Please refer to Figure 2. Figure 2 is a schematic flow chart of a JS code testing method provided by an embodiment of the present invention. The JS code testing method is applied to the electronic device shown in Figure 1. The specific flow of the JS code testing method is described below in conjunction with Figure 2. and steps are explained in detail. It should be noted that the method provided by the present invention is not limited to the order shown in Figure 2 and below. The specific process and steps of the JS code testing method will be described in detail below in conjunction with Figure 2.

步骤S100,获取待测试JS代码,以及与待测试JS代码对应的第一配置文件。Step S100: Obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested.

第一配置文件为预先创建,用于测试待测试JS代码相对于预设浏览器集合的兼容性。其中,预设浏览器集合中包括多个不同类型的浏览器,例如,IE浏览器、谷歌浏览器、火狐浏览器、360安全浏览器、搜狗浏览器、世界之窗浏览器等浏览器中的多个。本发明实施例中,将以预设浏览器集合中包括IE浏览器、谷歌浏览器、火狐浏览器为例,对JS代码测试方法的具体流程及步骤进行详细阐述。The first configuration file is created in advance and is used to test the compatibility of the JS code to be tested with respect to the preset browser collection. Among them, the default browser collection includes multiple different types of browsers, such as IE, Google Chrome, Firefox, 360 Secure Browser, Sogou Browser, World Window Browser and other browsers. Multiple. In the embodiment of the present invention, the specific process and steps of the JS code testing method will be described in detail, taking the default browser set including IE, Google Chrome, and Firefox as examples.

步骤S200,基于第一配置文件同时测试待测试JS代码相对于预设浏览器集合的兼容性,获得待测试JS代码的代码兼容性测试结果。Step S200: Simultaneously test the compatibility of the JS code to be tested with respect to the preset browser set based on the first configuration file, and obtain the code compatibility test results of the JS code to be tested.

待测试JS代码中包括至少一个目标JS函数。其中,目标JS函数为由事件驱动,或当其被调用时执行用于实现对应功能的可重复使用代码块。例如,函数currentStyle()、函数getComputedStyle()、函数const()等JS函数。The JS code to be tested includes at least one target JS function. Among them, the target JS function is event-driven, or executes a reusable code block to implement the corresponding function when it is called. For example, JS functions such as function currentStyle(), function getComputedStyle(), function const(), etc.

本发明实施例中,第一配置文件中可以包括至少一条用于表征JS函数相对于预设浏览器集合不兼容的函数兼容性信息。需要说明的是,本发明实施例中,针对某JS函数,其在预设浏览器集合中存在不兼容的浏览器,则相对于预设浏览器集合不兼容。基于此,基于第一配置文件同时测试待测试JS代码相对于预设浏览器集合的兼容性,获得待测试JS代码的代码兼容性测试结果,可以包括以下步骤。In this embodiment of the present invention, the first configuration file may include at least one piece of function compatibility information used to indicate that the JS function is incompatible with the preset browser set. It should be noted that in the embodiment of the present invention, if a certain JS function has an incompatible browser in the default browser set, it is incompatible with the default browser set. Based on this, simultaneously testing the compatibility of the JS code to be tested with respect to the preset browser set based on the first configuration file and obtaining the code compatibility test results of the JS code to be tested may include the following steps.

基于至少一条函数兼容性信息,分别确定待测试JS代码中的各个目标JS函数相对于预设浏览器集合的函数兼容性测试结果,并根据待测试JS代码中的所有目标JS函数的函数兼容性测试结果,确定待测试JS代码的代码兼容性测试结果。其中,若待测试JS代码中的所有目标JS函数均相对于预设浏览器集合兼容,则将待测试JS代码的代码兼容性测试结果确定为兼容,否则,将待测试JS代码的代码兼容性测试结果确定为不兼容。Based on at least one piece of function compatibility information, determine the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser collection, and based on the function compatibility of all target JS functions in the JS code to be tested Test results, determine the code compatibility test results of the JS code to be tested. Among them, if all target JS functions in the JS code to be tested are compatible with the preset browser set, the code compatibility test result of the JS code to be tested will be determined to be compatible; otherwise, the code compatibility of the JS code to be tested will be determined as compatible. The test results determined that it is incompatible.

进一步地,本发明实施例中,基于至少一条函数兼容性信息,分别确定待测试JS代码中的各个目标JS函数相对于预设浏览器集合的函数兼容性测试结果,可以包括以下步骤。Further, in the embodiment of the present invention, based on at least one piece of function compatibility information, determining the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set may include the following steps.

针对待测试JS代码中的每个目标JS函数,分别判断第一配置文件中是否存在与目标JS函数对应的函数兼容性信息。由于,本发明实施例中,函数兼容性信息是用于表征JS函数相对于预设浏览器集合不兼容的,因此,若第一配置文件中存在与目标JS函数对应的函数兼容性信息,则根据函数兼容性信息确定目标JS函数的函数兼容性测试结果,否则,将目标JS函数的函数兼容性测试结果确定为兼容。For each target JS function in the JS code to be tested, determine whether there is function compatibility information corresponding to the target JS function in the first configuration file. Since, in the embodiment of the present invention, the function compatibility information is used to indicate that the JS function is incompatible with the default browser set, therefore, if there is function compatibility information corresponding to the target JS function in the first configuration file, then The function compatibility test result of the target JS function is determined according to the function compatibility information; otherwise, the function compatibility test result of the target JS function is determined to be compatible.

可选地,本发明实施例中,函数兼容性信息包括函数标签和与函数标签对应的函数内容,每个函数标签对应一JS函数,函数内容用于表征与函数标签对应的JS函数相对于预设浏览器集合中的浏览器的兼容性。Optionally, in this embodiment of the present invention, the function compatibility information includes function labels and function content corresponding to the function labels. Each function label corresponds to a JS function, and the function content is used to characterize the JS function corresponding to the function label relative to the preset function. Assume the compatibility of the browsers in the browser collection.

例如,函数兼容性信息可以为″currentStyle″:″true:IE″,其中,″currentStyle″为函数标签,其对应的JS函数为currentStyle(),JS函数currentStyle()的对应功能为获取html页面元素的非行间样式,″true:IE″为函数内容,用于表征JS函数currentStyle()相对于预设浏览器集合中的IE浏览器兼容,也即,相对于预设浏览器集合中的谷歌浏览器和火狐浏览器不兼容,因此,可以理解的是,该函数兼容性信息也可以写作“″currentStyle″:″false:Chrome,Firefox″”。本发明实施例中,为保证代码的简洁性,优选写作“″currentStyle″:″true:IE″”。再例如,函数兼容性信息可以为″getComputedStyle″:″false:IE″,其中,″getComputedStyle″为函数标签,其对应的JS函数为getComputedStyle(),JS函数getComputedStyle()的对应功能为获取html页面元素的非行间样式,″false:IE″为函数内容,用于表征JS函数getComputedStyle()相对于预设浏览器集合中的IE浏览器不兼容,也即,相对于预设浏览器集合中的谷歌浏览器和火狐浏览器兼容,因此,可以理解的是,该函数兼容性信息也可以写作″getComputedStyle:″true:Chrome,Firefox″。本发明实施例中,为保证代码的简洁性,优选写作″getComputedStyle″:″false:IE″。又例如,函数兼容性信息可以为″setAttribute″:″false:IE″,其中,″setAttribute″为函数标签,其对应的JS函数为setAttribute(),JS函数setAttribute()的对应功能为设置对象属性,″false:IE″为函数内容,用于表征JS函数setAttribute()相对于预设浏览器集合中的IE浏览器不兼容,也即,相对于预设浏览器集合中的谷歌浏览器和火狐浏览器兼容,因此,可以理解的是,该函数兼容性信息也可以写作″const″:″false:Chrome,Firefox″。本发明实施例中,为保证代码的简洁性,优选写作″setAttribute″:″true:Firefox″。For example, the function compatibility information can be "currentStyle": "true: IE", where "currentStyle" is a function label, its corresponding JS function is currentStyle(), and the corresponding function of the JS function currentStyle() is to obtain html page elements The non-interline style, "true: IE" is the function content, which is used to indicate that the JS function currentStyle() is compatible with the IE browser in the default browser collection, that is, relative to Google Chrome in the default browser collection The browser is not compatible with Firefox, so it is understandable that the function compatibility information can also be written as ""currentStyle": "false: Chrome, Firefox"". In the embodiment of the present invention, in order to ensure the simplicity of the code, it is preferably written as ""currentStyle":"true:IE"". For another example, the function compatibility information can be "getComputedStyle": "false: IE", where "getComputedStyle" is a function label, its corresponding JS function is getComputedStyle(), and the corresponding function of the JS function getComputedStyle() is to obtain an html page The non-interline style of the element, "false: IE" is the function content, which is used to indicate that the JS function getComputedStyle() is incompatible with the IE browser in the default browser collection, that is, relative to the IE browser in the default browser collection Google Chrome and Firefox are compatible. Therefore, it is understandable that the function compatibility information can also be written as "getComputedStyle: "true: Chrome, Firefox". In the embodiment of the present invention, in order to ensure the simplicity of the code, it is preferably written as "getComputedStyle": "false: IE". For another example, the function compatibility information can be "setAttribute": "false: IE", where "setAttribute" is a function label, and its corresponding JS function is setAttribute(), and the JS function The corresponding function of setAttribute() is to set object attributes, and "false: IE" is the function content, which is used to indicate that the JS function setAttribute() is incompatible with the IE browser in the default browser collection, that is, relative to the default Google Chrome and Firefox in the browser collection are compatible. Therefore, it is understandable that the function compatibility information can also be written as "const": "false: Chrome, Firefox". In the embodiment of the present invention, in order to ensure that the code For simplicity, it is better to write "setAttribute":"true:Firefox".

由上可知,待测试JS代码中可能会出现同时包括两种不同的JS函数,而这两种JS函数的对应功能相同,但兼容的浏览器不同的情况。例如,JS函数currentStyle()和JS函数getComputedStyle()对应功能相同,但JS函数currentStyle()兼容IE浏览器,JS函数getComputedStyle()兼容谷歌浏览器和火狐浏览器。针对这种情况,本发明实施例中,第一配置文件还设置了预设信息关联情况,用于确定函数兼容性信息的关联类型,关联类型包括第一关联类型和第二关联类型。第一关联类型用于表征在第一配置文件中不存在与函数兼容信息功能关联的函数兼容性信息,例如,函数兼容性信息″setAttribute″:″false:IE″。第二关联类型用于表征在第一配置文件中存在与函数兼容信息功能关联的函数兼容性信息,例如,函数兼容性信息″currentStyle″:″true:IE″和函数兼容性信息″getComputedStyle″:″false:IE″。在实际实施时,为保证代码的整洁性,可以将关联类型为第二关联类型的函数兼容性信息与其功能关联的函数兼容性信息写作一条整体信息,例如,将函数兼容性信息″currentStyle″:″true:IE″和函数兼容性信息″getComputedStyle″:″false:IE″写作″currentStyle″:″true:IE″;″getComputedStyle″:″true:Chrome,Firefox″。It can be seen from the above that the JS code to be tested may include two different JS functions at the same time, and the corresponding functions of these two JS functions are the same but compatible with different browsers. For example, the JS function currentStyle() and the JS function getComputedStyle() have the same functions, but the JS function currentStyle() is compatible with IE browser, and the JS function getComputedStyle() is compatible with Google Chrome and Firefox. To address this situation, in the embodiment of the present invention, the first configuration file also sets a preset information association situation, which is used to determine the association type of the function compatibility information. The association type includes a first association type and a second association type. The first association type is used to represent that there is no function compatibility information functionally associated with the function compatibility information in the first configuration file, for example, function compatibility information "setAttribute": "false: IE". The second association type is used to represent that there is function compatibility information functionally associated with the function compatibility information in the first configuration file, for example, function compatibility information "currentStyle": "true:IE" and function compatibility information "getComputedStyle": "false: IE". In actual implementation, in order to ensure the cleanliness of the code, the function compatibility information whose associated type is the second associated type and the function compatibility information associated with its function can be written as one overall message, for example, the function compatibility information "currentStyle": "true: IE" and function compatibility information "getComputedStyle": "false: IE" are written as "currentStyle": "true: IE"; "getComputedStyle": "true: Chrome, Firefox".

基于以上描述,本发明实施例中,根据函数兼容性信息确定目标JS函数的函数兼容性测试结果,可以包括以下步骤。Based on the above description, in the embodiment of the present invention, determining the function compatibility test result of the target JS function based on the function compatibility information may include the following steps.

确定函数兼容信息的关联类型。若函数兼容信息的关联类型为第一关联类型,则根据函数兼容信息,确定目标JS函数的函数兼容性测试结果,本发明实施例中,也即,确定目标JS函数的函数兼容性测试结果为不兼容。若函数兼容信息的关联类型为第二关联类型,则根据函数兼容信息的函数内容以及与函数兼容信息功能关联的函数兼容性信息的函数内容,确定目标JS函数的函数兼容性测试结果。Determines the associated type of function compatibility information. If the association type of the function compatibility information is the first association type, the function compatibility test result of the target JS function is determined according to the function compatibility information. In the embodiment of the present invention, that is, the function compatibility test result of the target JS function is determined to be Not compatible. If the association type of the function compatibility information is the second association type, the function compatibility test result of the target JS function is determined based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information.

在实际实施时,首先,可以根据函数兼容信息的函数内容,获得对与函数兼容信息对应的JS函数兼容的浏览器,作为第一浏览器。再将与函数兼容信息功能关联的函数兼容性信息,作为关联函数兼容性信息,并根据关联函数兼容性信息的函数内容,获得对与关联函数兼容信息对应的JS函数兼容的浏览器,作为第二浏览器。最后,判断第一浏览器与第二浏览器的集合是否与预设浏览器集合相同。若第一浏览器与第二浏览器的集合与预设浏览器集合相同,则确定目标JS函数的函数兼容性测试结果为兼容,否则,确定目标JS函数的函数兼容性测试结果为不兼容。In actual implementation, first, according to the function content of the function compatibility information, a browser compatible with the JS function corresponding to the function compatibility information can be obtained as the first browser. Then, the function compatibility information associated with the function compatibility information function is used as the associated function compatibility information, and based on the function content of the associated function compatibility information, a browser compatible with the JS function corresponding to the associated function compatibility information is obtained as the third Two browsers. Finally, it is determined whether the set of the first browser and the second browser is the same as the default browser set. If the set of the first browser and the second browser is the same as the preset browser set, it is determined that the function compatibility test result of the target JS function is compatible; otherwise, it is determined that the function compatibility test result of the target JS function is incompatible.

例如,当待测试JS代码中同时包括JS函数currentStyle()和JS函数getComputedStyle()时,可以根据第一配置文件中的函数兼容信息″currentStyle″:″true:IE″,获得对JS函数currentStyle()兼容的浏览器,也即IE浏览器,作为第一浏览器,同时,将与函数兼容信息″currentStyle″:″true:IE″关联的函数兼容性信息″getComputedStyle″:″false:IE″作为关联函数兼容信息,并获得对JS函数getComputedStyle()兼容的浏览器,也即谷歌浏览器和火狐浏览器,作为第二浏览器。第一浏览器和第二浏览器的集合与预设浏览器相同,则确定JS函数currentStyle()的函数兼容性测试结果为兼容。经同样的判断方式,也可以确定JS函数getComputedStyle()的函数兼容性测试结果为兼容。For example, when the JS code to be tested includes both the JS function currentStyle() and the JS function getComputedStyle(), the function compatibility of the JS function currentStyle() can be obtained based on the function compatibility information "currentStyle": "true: IE" in the first configuration file. ) compatible browser, that is, the IE browser, is used as the first browser, and at the same time, the function compatibility information "getComputedStyle": "false: IE" associated with the function compatibility information "currentStyle": "true: IE" is used as Associated function compatibility information, and obtains browsers compatible with the JS function getComputedStyle(), that is, Google Chrome and Firefox, as the second browser. If the set of the first browser and the second browser is the same as the default browser, it is determined that the function compatibility test result of the JS function currentStyle() is compatible. Through the same judgment method, it can also be determined that the function compatibility test result of the JS function getComputedStyle() is compatible.

为进一步判断目标JS函数相对于预设浏览器集合的不兼容程度,本发明实施例中,第一配置文件还设置了预设浏览器兼容性情况,用于确定函数兼容性信息的不兼容类型,不兼容类型包括第一不兼容类型和第二不兼容类型。第一不兼容类型用于表征函数兼容性信息的不兼容情况为完全不兼容,第二不兼容类型用于表征函数兼容性信息的不兼容情况为不完全兼容。针对某条函数兼容性信息,若其不兼容类型为第一不兼容类型,则其表征的JS函数在预设浏览器集合中不兼容的浏览器上无法实现对应功能,若其不兼容类型为第二不兼容类型,则其表征的JS函数在预设浏览器集合中不兼容的浏览器上可以实现对应功能,但实现效果无法满足预设要求。In order to further determine the degree of incompatibility of the target JS function with respect to the preset browser set, in the embodiment of the present invention, the first configuration file also sets the preset browser compatibility status, which is used to determine the incompatibility type of the function compatibility information. , the incompatible type includes a first incompatible type and a second incompatible type. The first incompatibility type is used to characterize the incompatibility of the function compatibility information as complete incompatibility, and the second incompatibility type is used to characterize the incompatibility of the function compatibility information as incomplete compatibility. For a certain piece of function compatibility information, if its incompatibility type is the first incompatibility type, the JS function represented by it cannot implement the corresponding function on an incompatible browser in the default browser collection. If its incompatibility type is The second incompatible type means that the JS function represented by it can implement the corresponding function on incompatible browsers in the default browser collection, but the implementation effect cannot meet the preset requirements.

例如,第一配置文件中具有函数兼容性信息″setAttribute″:″false:IE″和函数兼容性信息″str″:″false:IE6,IE7″,而JS函数setAttribute()的对应功能在IE浏览器上无法实现,则将函数兼容性信息″setAttribute″:″false:IE″的不兼容类型判定为第一不兼容类型,JS函数str()的对应功能在IE6和IE7上可以实现对应功能,但实现效果无法满足预设要求,则将函数兼容性信息″str″:″false:IE6,IE7″的不兼容类型判定为第二不兼容类型。在实际实施时,为保证代码的整洁性,可以将不兼容类型为第一不兼容类型的函数兼容性信息写入一个程序段,再将不兼容类型为第二不兼容类型的函数兼容性信息写入另一个程序段,例如,将不兼容类型为第一不兼容类型的函数兼容性信息写入程序段″block″{...},将不兼容类型为第二不兼容类型的函数兼容性信息写入程序段″warning″{...}For example, the first configuration file has function compatibility information "setAttribute": "false: IE" and function compatibility information "str": "false: IE6, IE7", and the corresponding function of the JS function setAttribute() is in IE browsing If it cannot be implemented on the device, the incompatible type of the function compatibility information "setAttribute": "false: IE" will be determined as the first incompatible type. The corresponding function of the JS function str() can be implemented on IE6 and IE7. However, the implementation effect cannot meet the preset requirements, and the incompatibility type of the function compatibility information "str": "false: IE6, IE7" is determined as the second incompatibility type. In actual implementation, in order to ensure the cleanliness of the code, the function compatibility information of the first incompatible type can be written into a program segment, and then the function compatibility information of the second incompatible type can be written into Write another program segment, for example, write the function compatibility information of the first incompatible type into the program segment "block" {...}, and make the function compatibility information of the second incompatible type compatible Sexual information is written into the program segment "warning"{...}

基于以上描述,本发明实施例中,当目标JS函数的函数兼容性测试结果为不兼容时,根据函数兼容性信息确定目标JS函数的函数兼容性测试结果,还可以包括以下步骤。Based on the above description, in the embodiment of the present invention, when the function compatibility test result of the target JS function is incompatible, determining the function compatibility test result of the target JS function based on the function compatibility information may also include the following steps.

判断函数兼容性信息的不兼容类型,若函数兼容性信息的不兼容类型为第一不兼容类型,则将目标JS函数的函数兼容性结果确定为完全不兼容,若函数兼容性信息的不兼容类型为第二不兼容类型,则目标JS函数的函数兼容性结果确定为不完全兼容。Determine the incompatibility type of the function compatibility information. If the incompatibility type of the function compatibility information is the first incompatibility type, then determine the function compatibility result of the target JS function as completely incompatible. If the incompatibility of the function compatibility information is If the type is the second incompatible type, the function compatibility result of the target JS function is determined to be not fully compatible.

本发明实施例中,在获得待测试JS代码的代码兼容性测试结果之后,还可以根据代码兼容性测试结果生成代码兼容性测试报告。代码兼容性测试报告中可以包括各个函数兼容性测试结果为完全不兼容的目标函数,以及各自对应的预设浏览器集合中完全不兼容的浏览器,同样,代码兼容性测试报告中还可以包括各个函数兼容性测试结果为不完全兼容的目标函数,以及各自对应的预设浏览器集合中不完全兼容的浏览器。In the embodiment of the present invention, after obtaining the code compatibility test results of the JS code to be tested, a code compatibility test report can also be generated based on the code compatibility test results. The code compatibility test report can include the target functions for which each function compatibility test result is completely incompatible, as well as the completely incompatible browsers in the corresponding preset browser set. Similarly, the code compatibility test report can also include The compatibility test results of each function are the target functions that are not fully compatible, and the browsers that are not fully compatible in the corresponding default browser set.

以下将举例对基于第一配置文件同时测试待测试JS代码相对于预设浏览器集合的兼容性,获得待测试JS代码的代码兼容性测试结果的整体过程进行进行说明。The following will take an example to illustrate the overall process of simultaneously testing the compatibility of the JS code to be tested with respect to the preset browser set based on the first configuration file and obtaining the code compatibility test results of the JS code to be tested.

例如,第一配置文件为:For example, the first configuration file is:

待测试代码包括的目标函数为JS函数cursor:hand()、JS函数currentStyle()、JS函数getComputedStyle()、JS函数″setAttribute″()和JS函数str()。The target functions included in the code to be tested are JS function cursor: hand(), JS function currentStyle(), JS function getComputedStyle(), JS function "setAttribute"() and JS function str().

针对JS函数cursor:hand(),第一配置文件中不存在与JS函数cursor:hand()对应的函数兼容性信息,则JS函数cursor:hand()的函数兼容性测试结果确定为兼容。Regarding the JS function cursor:hand(), if there is no function compatibility information corresponding to the JS function cursor:hand() in the first configuration file, then the function compatibility test result of the JS function cursor:hand() is determined to be compatible.

针对JS函数currentStyle(),第一配置文件中存在与JS函数currentStyle()对应的函数兼容性信息″currentStyle″:″true:IE″,函数兼容性信息″currentStyle″:″true:IE″的关联类型为第二关联类型,且函数兼容性信息″currentStyle″:″true:IE″的关联函数兼容性信息为″getComputedStyle″:″false:IE″。进一步地,与对JS函数currentStyle()兼容的浏览器为IE浏览器,对JS函数getComputedStyle()兼容的浏览器为谷歌浏览器和火狐浏览器,IE浏览器、谷歌浏览器和火狐浏览器的集合与预设浏览器集合相同,所以JS函数currentStyle()的函数兼容性测试结果确定为兼容。经同样的判断方式,获得JS函数getComputedStyle()的函数兼容性测试结果也为兼容。可以理解的是,若待测试JS代码中存在JS函数currentStyle(),而不存在JS函数getComputedStyle(),则JS函数currentStyle()的函数兼容性测试结果确定为不兼容,同样,若待测试JS代码中存在JS函数getComputedStyle(),而不存在JS函数currentStyle(),则JS函数getComputedStyle()的函数兼容性测试结果确定为不兼容。Regarding the JS function currentStyle(), there is an association in the first configuration file with the function compatibility information "currentStyle": "true: IE" corresponding to the JS function currentStyle() and the function compatibility information "currentStyle": "true: IE" The type is the second associated type, and the associated function compatibility information of the function compatibility information "currentStyle": "true: IE" is "getComputedStyle": "false: IE". Further, the browsers compatible with the JS function currentStyle() are IE browsers, the browsers compatible with the JS function getComputedStyle() are Google Chrome and Firefox, and the browsers of IE, Google Chrome and Firefox The collection is the same as the default browser collection, so the function compatibility test result of the JS function currentStyle() is determined to be compatible. After the same judgment method, the function compatibility test result of the JS function getComputedStyle() is also compatible. It can be understood that if the JS function currentStyle() exists in the JS code to be tested, but the JS function getComputedStyle() does not exist, the function compatibility test result of the JS function currentStyle() is determined to be incompatible. Similarly, if the JS function to be tested does not If the JS function getComputedStyle() exists in the code, but the JS function currentStyle() does not exist, the function compatibility test result of the JS function getComputedStyle() is determined to be incompatible.

针对JS函数″setAttribute″(),第一配置文件中存在与JS函数″setAttribute″()对应的函数兼容性信息″setAttribute″:″false:IE″,且JS函数″setAttribute″()的关联类型为第一关联类型,则JS函数″setAttribute″()的函数兼容性测试结果确定为不兼容,进一步地,由于函数兼容性信息″setAttribute″:″false:IE″的不兼容类型为第一不兼容类型,则可以进一步确定JS函数″setAttribute″()的函数兼容性测试结果确定为完全不兼容。For the JS function "setAttribute" (), there is function compatibility information "setAttribute" corresponding to the JS function "setAttribute" () in the first configuration file: "false: IE", and the associated type of the JS function "setAttribute" () is the first association type, then the function compatibility test result of the JS function "setAttribute"() is determined to be incompatible. Furthermore, because the incompatibility type of the function compatibility information "setAttribute": "false: IE" is the first incompatibility Compatible type, it can be further determined that the function compatibility test result of the JS function "setAttribute"() is determined to be completely incompatible.

针对JS函数str(),第一配置文件中存在与JS函数str()对应的函数兼容性信息″str″:″false:IE6,IE7″,且JS函数str()的关联类型为第一关联类型,则JS函数str()的函数兼容性测试结果确定为不兼容,进一步地,由于函数兼容性信息″str″:″false:IE6,IE7″的不兼容类型为第二不兼容类型,则可以进一步确定JS函数str()的函数兼容性测试结果确定为不完全兼容。For the JS function str(), there is function compatibility information "str" corresponding to the JS function str() in the first configuration file: "false: IE6, IE7", and the association type of the JS function str() is the first association type, then the function compatibility test result of the JS function str() is determined to be incompatible. Furthermore, since the incompatible type of the function compatibility information "str": "false: IE6, IE7" is the second incompatible type, then It can be further determined that the function compatibility test result of the JS function str() is determined to be not fully compatible.

此后,确定待测试JS代码的代码兼容性测试结果为不兼容,且可以生成包括JS函数″setAttribute″完全不兼容IE浏览器,JS函数str()不完全兼容IE6浏览器和IE7浏览器的代码兼容性测试报告。After that, it is determined that the code compatibility test result of the JS code to be tested is incompatible, and the code including the JS function "setAttribute" that is completely incompatible with IE browser, and the JS function str() that is not fully compatible with IE6 browser and IE7 browser can be generated. Compatibility test report.

可选地,本发明实施例中,JS代码测试方法,还包括:Optionally, in this embodiment of the present invention, the JS code testing method also includes:

步骤S300,获取待测试JS代码对应的第二配置文件。Step S300: Obtain the second configuration file corresponding to the JS code to be tested.

第二配置文件为预先创建,用于测试待测试JS代码的语法规范性。The second configuration file is created in advance and is used to test the syntax standardization of the JS code to be tested.

步骤S400,基于第二配置文件测试待测试JS代码的语法规范性,获得待测试JS代码的代码语法规范性测试结果。Step S400: Test the syntax standardization of the JS code to be tested based on the second configuration file, and obtain the code syntax standardization test result of the JS code to be tested.

本发明实施例中,第二配置文件中可以包括至少一条用于表征JS函数具有的语法不规范问题的语法规范性信息。基于此,基于第二配置文件测试待测试JS代码的语法规范性,获得待测试JS代码的代码语法规范性测试结果,可以包括以下步骤。In this embodiment of the present invention, the second configuration file may include at least one piece of grammatical normative information used to characterize the grammatical irregularities of the JS function. Based on this, testing the syntax standardization of the JS code to be tested based on the second configuration file and obtaining the code syntax standardization test results of the JS code to be tested may include the following steps.

针对每条语法规范性信息,判断待测试JS代码中是否存在与语法规范性信息对应的语法设置。若待测试JS代码中存在与语法规范性信息对应的语法设置,则将语法设置作为不规范语法。若JS代码中存在不规范语法,则确定待测试JS代码的代码语法规范性测试结果为不规范,否则,确定待测试JS代码的代码语法规范性测试结果为规范。For each piece of grammatical normative information, determine whether there is a grammatical setting corresponding to the grammatical normative information in the JS code to be tested. If there is a syntax setting corresponding to the syntax normative information in the JS code to be tested, the syntax setting will be regarded as non-standard syntax. If there is irregular syntax in the JS code, it is determined that the code syntax normative test result of the JS code to be tested is irregular; otherwise, the code syntax normative test result of the JS code to be tested is determined to be normative.

可选地,本发明实施例中,语法规范性信息包括语法标签和与语法标签对应的判断标准内容,每个语法标签对应一语法设置,判断标准内容用于表征与语法标签对应的语法设置的语法规范性为不规范。Optionally, in the embodiment of the present invention, the grammar normative information includes grammar tags and judgment standard content corresponding to the grammar tags. Each grammar tag corresponds to a grammar setting, and the judgment standard content is used to characterize the grammar setting corresponding to the grammar tag. Grammatical normativity is irregular.

例如,语法规范性信息可以为″bitwise″:true,其中,″bitwise″为语法标签,其对应的语法设置为是否在JS代码中设置了禁用位运算符(如^,&),true为判断标准内容,用于表征若待测试JS代码中设置了禁用位运算符(如^,&),则确认待测试JS代码的代码中的该语法设置为不规范语法,并可以进一步确认待测试JS代码的代码语法规范性测试结果为不规范。再例如,语法规范性信息可以为″curly″:true,其中,″curly″为语法标签,其对应的语法设置为是否在if和while等语句中使用{}来明确代码块,true为判断标准内容,用于表征若待测试JS代码中在if和while等语句中使用{}来明确代码块,则确认待测试JS代码的代码中的该语法设置为不规范语法,并可以进一步确认待测试JS代码的代码语法规范性测试结果为不规范。又例如,″noarg″:true,其中,″noarg″为语法标签,其对应的语法设置为是否使用了arguments.caller和arguments.callee,true为判断标准内容,用于表征若待测试JS代码中使用了arguments.caller和arguments.callee,则确认待测试JS代码的代码中的该语法设置为不规范语法,并可以进一步确认待测试JS代码的代码语法规范性测试结果为不规范。For example, the syntax normative information can be "bitwise": true, where "bitwise" is the syntax tag, and its corresponding syntax setting is whether disabled bit operators (such as ^, &) are set in the JS code, and true is the judgment Standard content, used to indicate that if disabled bit operators (such as ^, &) are set in the JS code to be tested, it is confirmed that the syntax in the code of the JS code to be tested is set to non-standard syntax, and it can further confirm that the JS code to be tested is not standardized. The code syntax standardization test result of the code is irregular. For another example, the grammar normative information can be "curly": true, where "curly" is a grammar label, and its corresponding grammar setting is whether to use {} in statements such as if and while to clarify code blocks, and true is the judgment criterion. Content, used to represent that if {} is used in statements such as if and while to clarify the code block in the JS code to be tested, it is confirmed that the syntax in the code of the JS code to be tested is set to non-standard syntax, and it can be further confirmed that the code to be tested is The code syntax standardization test result of JS code is non-standard. For another example, "noarg": true, where "noarg" is a syntax tag, and its corresponding syntax setting is whether arguments.caller and arguments.callee are used. true is the judgment standard content, which is used to characterize the JS code to be tested. If arguments.caller and arguments.callee are used, it is confirmed that the syntax setting in the code of the JS code to be tested is non-standard syntax, and it can be further confirmed that the code syntax normative test result of the JS code to be tested is non-standard.

为了进一步判断目标JS函数的语法不规范程度,本发明实施例中,第二配置文件还设置了预设语法规范性情况,用于确定语法规范性信息的不规范类型,,不规范类型包括第一不规范类型和第二不规范类型,第一不规范类型用于表征语法规范性信息的语法不规范问题为完全不规范,第二不规范类型用于表征语法规范性信息的不规范问题为不完全规范。针对某个不规范语法,若其对应的语法规范性信息的不规范类型为第一不规范类型,则其表征在JS代码中使用该不规范语法会使得JS代码无法被执行,而实现各JS函数的对应功能,若其对应的语法规范性信息的不规范类型为第二不规范类型,则其表征在JS代码中使用该不规范语法会使得JS代码可以被执行,而实现各JS函数的对应功能,但实现效果无法满足预设要求。In order to further determine the degree of grammatical irregularity of the target JS function, in the embodiment of the present invention, the second configuration file also sets a preset grammatical normative situation, which is used to determine the irregularity type of the grammatical normative information. The irregularity type includes the first The first irregularity type and the second irregularity type. The first irregularity type is used to represent grammatical normative information. The grammatical irregularities are completely irregular. The second irregularity type is used to represent grammatical normative information. The irregularity is Not completely standardized. For a certain non-standard grammar, if the non-standard type of the corresponding grammatical normative information is the first non-standard type, it means that using the non-standard syntax in JS code will make the JS code unable to be executed, and the implementation of various JS The corresponding function of the function, if the non-standard type of the corresponding syntax normative information is the second non-standard type, it means that using the non-standard syntax in the JS code will enable the JS code to be executed, and realize the implementation of each JS function. Corresponding function, but the implementation effect cannot meet the preset requirements.

例如,第二配置文件中具有语法规范性信息″bitwise″:true和″noarg″:true,由于在JS代码中设置了禁用位运算符(如^,&)会使得JS代码无法被执行,而实现各JS函数的对应功能,则将″bitwise″:true的不规范类型确认为第一不规范类型,由于在JS代码中使用arguments.caller和arguments.callee,JS代码可以被执行,而实现各JS函数的对应功能,但实现效果无法满足预设要求,则将″noarg″:true的不规范类型确认为第二不规范类型。在实际实施时,为保证代码的整洁性,可以将不规范类型为第一不规范类型的语法规范性信息写入一个程序段,再将不规范类型为第二不规范类型的语法规范性信息写入另一个程序段,例如,将不规范类型为第一不规范类型的语法规范性信息写入程序段″block″{...},将不规范类型为第二不规范类型的语法规范性信息写入程序段″warning″{...}For example, the second configuration file has syntax normative information "bitwise": true and "noarg": true. Since disabled bit operators (such as ^, &) are set in the JS code, the JS code cannot be executed. To realize the corresponding functions of each JS function, the non-standard type of "bitwise": true is confirmed as the first non-standard type. Since arguments.caller and arguments.callee are used in the JS code, the JS code can be executed, and various The corresponding function of the JS function, but the implementation effect cannot meet the preset requirements, then the non-standard type with "noarg": true is confirmed as the second non-standard type. In actual implementation, in order to ensure the cleanliness of the code, the grammatical normative information of the irregular type as the first irregular type can be written into a program segment, and then the grammatical normative information of the irregular type as the second irregular type can be written into a program segment. Write another program segment, for example, write the syntax specification information of the first irregular type into the program segment "block" {...}, and write the syntax specification information of the second irregular type into the program segment "block" {...} Sexual information is written into the program segment "warning"{...}

基于以上描述,本发明实施例中,若待测试JS代码中存在与语法规范性信息对应的语法设置,则将语法设置作为不规范语法,具体可以包括以下步骤。Based on the above description, in the embodiment of the present invention, if there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is used as non-standard grammar. Specifically, the following steps may be included.

判断语法规范性信息的不规范类型,若语法规范性信息的不规范类型为第一不规范类型,则将语法设置作为完全不规范语法,若语法规范性信息的不规范类型为第二不规范类型,则将语法设置作为完全不完全规范语法。Determine the irregularity type of the grammatical normative information. If the irregularity type of the grammatical normative information is the first irregularity type, set the grammar as a completely irregular grammar. If the irregularity type of the grammatical normative information is the second irregularity type type, sets the grammar as a completely incomplete canonical grammar.

本发明实施例中,在获得待测试JS代码的代码语法规范性测试结果之后,还可以根据代码语法规范性测试结果生成代码语法规范性性测试报告。代码语法规范性性测试报告中可以包括各个不规范语法,以及各自对应的不规范类型。In the embodiment of the present invention, after obtaining the code syntax normative test results of the JS code to be tested, a code syntax normative test report can also be generated based on the code syntax normative test results. The code syntax normative test report can include each irregular syntax and its corresponding irregularity type.

以下将举例对基于第二配置文件测试待测试JS代码的语法规范性,获得待测试JS代码的代码语法规范性测试结果的整体过程进行进行说明。The following will take an example to illustrate the overall process of testing the syntax standardization of the JS code to be tested based on the second configuration file and obtaining the code syntax standardization test results of the JS code to be tested.

例如,第二配置文件为:For example, the second configuration file is:

待测试代码中设置了禁用位运算符(如^,&),且使用了使用了arguments.caller和arguments.callee。Disabled bit operators (such as ^, &) are set in the code to be tested, and arguments.caller and arguments.callee are used.

针对第一条语法规范性信息″bitwise″:true,确认待测试JS代码的代码语法规范性测试结果为不规范,且由于语法规范性信息″bitwise″:true的不规范类型为第一不规范类型,则确认待测试JS代码中设置的禁用位运算符(如^,&)为完全不规范语法。For the first piece of syntax normative information "bitwise": true, it is confirmed that the code syntax normative test result of the JS code to be tested is irregular, and because the irregularity type of the syntax normative information "bitwise": true is the first irregularity Type, confirm that the disabled bit operators (such as ^, &) set in the JS code to be tested are completely non-standard syntax.

针对第七条语法规范性信息″noarg″:true,确认待测试JS代码的代码语法规范性测试结果为不规范,且由于语法规范性信息″noarg″:true的不规范类型为第二不规范类型,则确认待测试JS代码中使用了arguments.caller和arguments.callee为不完全规范语法。Regarding the seventh grammatical normative information "noarg": true, confirm that the code syntax normative test result of the JS code to be tested is nonstandard, and the nonstandard type due to the grammatical normative information "noarg": true is the second irregularity Type, confirm that the arguments.caller and arguments.callee used in the JS code to be tested are incompletely standardized syntax.

基于与上述待发放虚拟网络资源预估方法同样的发明构思,本发明实施例还提供了一种JS代码测试装置110。请参阅图4,JS代码测试装置110包括第一配置文件获取模块111和第一测试结果获取模块112。Based on the same inventive concept as the above-mentioned method for estimating virtual network resources to be distributed, embodiments of the present invention also provide a JS code testing device 110. Referring to FIG. 4 , the JS code testing device 110 includes a first configuration file acquisition module 111 and a first test result acquisition module 112 .

第一配置文件获取模块,用于获取待测试JS代码,以及与待测试JS代码对应的第一配置文件。The first configuration file acquisition module is used to obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested.

关于第一配置文件获取模块111的描述具体可参考上述步骤S100的详细描述,也即,步骤S100可以由第一配置文件获取模块111执行,此处不再赘述。For a description of the first configuration file acquisition module 111, reference may be made to the detailed description of the above-mentioned step S100. That is, step S100 may be executed by the first configuration file acquisition module 111, and will not be described again here.

第一测试结果获取模块,用于基于第一配置文件同时测试待测试JS代码相对于预设浏览器集合的兼容性,获得待测试JS代码的代码兼容性测试结果。The first test result acquisition module is used to simultaneously test the compatibility of the JS code to be tested with respect to the preset browser set based on the first configuration file, and obtain the code compatibility test results of the JS code to be tested.

待测试JS代码中包括至少一个目标JS函数,第一配置文件中包括至少一条用于表征JS函数相对于预设浏览器集合不兼容的函数兼容性信息。基于此,可选地,本发明实施例中,第一测试结果获取模块,具体用于:The JS code to be tested includes at least one target JS function, and the first configuration file includes at least one piece of function compatibility information used to indicate that the JS function is incompatible with the preset browser set. Based on this, optionally, in the embodiment of the present invention, the first test result acquisition module is specifically used for:

基于至少一条函数兼容性信息,分别确定待测试JS代码中的各个目标JS函数相对于预设浏览器集合的函数兼容性测试结果;Based on at least one piece of function compatibility information, respectively determine the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set;

根据待测试JS代码中的所有目标JS函数的函数兼容性测试结果,确定待测试JS代码的代码兼容性测试结果;Determine the code compatibility test results of the JS code to be tested based on the function compatibility test results of all target JS functions in the JS code to be tested;

其中,若待测试JS代码中的所有目标JS函数均相对于预设浏览器集合兼容,则将待测试JS代码的代码兼容性测试结果确定为兼容,否则,将待测试JS代码的代码兼容性测试结果确定为不兼容。Among them, if all target JS functions in the JS code to be tested are compatible with the preset browser set, the code compatibility test result of the JS code to be tested will be determined to be compatible; otherwise, the code compatibility of the JS code to be tested will be determined as compatible. The test results determined that it is incompatible.

可选地,本发明实施例中,第一测试结果获取模块,又具体用于:Optionally, in the embodiment of the present invention, the first test result acquisition module is specifically used for:

针对待测试JS代码中的每个目标JS函数,分别判断第一配置文件中是否存在与目标JS函数对应的函数兼容性信息;For each target JS function in the JS code to be tested, determine whether there is function compatibility information corresponding to the target JS function in the first configuration file;

若第一配置文件中存在与目标JS函数对应的函数兼容性信息,则根据函数兼容性信息确定目标JS函数的函数兼容性测试结果,否则,将目标JS函数的函数兼容性测试结果确定为兼容。If there is function compatibility information corresponding to the target JS function in the first configuration file, the function compatibility test result of the target JS function is determined based on the function compatibility information; otherwise, the function compatibility test result of the target JS function is determined to be compatible. .

函数兼容性信息包括函数标签和与函数标签对应的函数内容,每个函数标签对应一JS函数,函数内容用于表征与函数标签对应的JS函数相对于预设浏览器集合中的浏览器的兼容性。基于此,可选地,本发明实施例中,第一测试结果获取模块,又具体用于:Function compatibility information includes function tags and function content corresponding to the function tag. Each function tag corresponds to a JS function. The function content is used to characterize the compatibility of the JS function corresponding to the function tag with respect to the browsers in the preset browser collection. sex. Based on this, optionally, in the embodiment of the present invention, the first test result acquisition module is specifically used for:

基于预设信息关联情况,确定函数兼容性信息的关联类型,关联类型包括第一关联类型和第二关联类型,第一关联类型用于表征在第一配置文件中不存在与函数兼容信息功能关联的函数兼容性信息,第二关联类型用于表征在第一配置文件中存在与函数兼容信息功能关联的函数兼容性信息;Based on the preset information association situation, the association type of the function compatibility information is determined. The association type includes a first association type and a second association type. The first association type is used to indicate that there is no functional association with the function compatibility information in the first configuration file. Function compatibility information, the second association type is used to represent that there is function compatibility information functionally associated with the function compatibility information in the first configuration file;

若函数兼容信息的关联类型为第一关联类型,则根据函数兼容信息,确定目标JS函数的函数兼容性测试结果;If the association type of the function compatibility information is the first association type, determine the function compatibility test result of the target JS function based on the function compatibility information;

若函数兼容信息的关联类型为第二关联类型,则根据函数兼容信息的函数内容以及与函数兼容信息功能关联的函数兼容性信息的函数内容,确定目标JS函数的函数兼容性测试结果。If the association type of the function compatibility information is the second association type, the function compatibility test result of the target JS function is determined based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information.

可选地,本发明实施例中,第一测试结果获取模块,又具体用于:Optionally, in the embodiment of the present invention, the first test result acquisition module is specifically used for:

根据函数兼容信息的函数内容,获得对与函数兼容信息对应的JS函数兼容的浏览器,作为第一浏览器;According to the function content of the function compatibility information, a browser compatible with the JS function corresponding to the function compatibility information is obtained as the first browser;

将与函数兼容信息功能关联的函数兼容性信息,作为关联函数兼容性信息,并根据关联函数兼容性信息的函数内容,获得对与关联函数兼容信息对应的JS函数兼容的浏览器,作为第二浏览器;The function compatibility information associated with the function compatibility information function is used as the associated function compatibility information, and based on the function content of the associated function compatibility information, a browser compatible with the JS function corresponding to the associated function compatibility information is obtained as the second browser;

判断第一浏览器与第二浏览器的集合是否与预设浏览器集合相同;Determine whether the set of the first browser and the second browser is the same as the default browser set;

若第一浏览器与第二浏览器的集合与预设浏览器集合相同,则确定目标JS函数的函数兼容性测试结果为兼容,否则,确定目标JS函数的函数兼容性测试结果为不兼容。If the set of the first browser and the second browser is the same as the preset browser set, it is determined that the function compatibility test result of the target JS function is compatible; otherwise, it is determined that the function compatibility test result of the target JS function is incompatible.

当目标JS函数的函数兼容性测试结果为不兼容时,可选地,本发明实施例中,第一测试结果获取模块,还具体用于:When the function compatibility test result of the target JS function is incompatible, optionally, in the embodiment of the present invention, the first test result acquisition module is also specifically used to:

基于预设浏览器兼容性情况,确定函数兼容性信息的不兼容类型,不兼容类型包括第一不兼容类型和第二不兼容类型,第一不兼容类型用于表征函数兼容性信息的不兼容情况为完全不兼容,第二不兼容类型用于表征函数兼容性信息的不兼容情况为不完全兼容;Based on the preset browser compatibility situation, the incompatibility type of the function compatibility information is determined. The incompatibility type includes a first incompatibility type and a second incompatibility type. The first incompatibility type is used to characterize the incompatibility of the function compatibility information. The situation is completely incompatible, and the incompatibility situation where the second incompatibility type is used to represent function compatibility information is incomplete compatibility;

若函数兼容性信息的不兼容类型为第一不兼容类型,则将目标JS函数的函数兼容性结果确定为完全不兼容;If the incompatibility type of the function compatibility information is the first incompatibility type, the function compatibility result of the target JS function is determined to be completely incompatible;

若函数兼容性信息的不兼容类型为第二不兼容类型,则目标JS函数的函数兼容性结果确定为不完全兼容。If the incompatible type of the function compatibility information is the second incompatible type, the function compatibility result of the target JS function is determined to be incompletely compatible.

关于第一测试结果获取模块112的描述具体可参考上述步骤S200的详细描述,也即,步骤S200可以由第一测试结果获取模块112执行,此处不再赘述。For a description of the first test result acquisition module 112, reference may be made to the detailed description of the above-mentioned step S200. That is, step S200 may be executed by the first test result acquisition module 112, and will not be described again here.

请参阅图5,可选地,本发明实施例中,JS代码测试装置,还包括:Please refer to Figure 5. Optionally, in this embodiment of the present invention, the JS code testing device also includes:

第二配置文件获取模块,用于获取待测试JS代码对应的第二配置文件。The second configuration file acquisition module is used to obtain the second configuration file corresponding to the JS code to be tested.

关于第二配置文件获取模块113的描述具体可参考上述步骤S300的详细描述,也即,步骤S300可以由第二配置文件获取模块113执行,此处不再赘述。For a description of the second configuration file acquisition module 113, reference may be made to the detailed description of the above-mentioned step S300. That is, step S300 may be executed by the second configuration file acquisition module 113, and will not be described again here.

第二测试结果获取模块,用于基于第二配置文件测试待测试JS代码的语法规范性,获得待测试JS代码的代码语法规范性测试结果。The second test result acquisition module is used to test the syntax standardization of the JS code to be tested based on the second configuration file, and obtain the code syntax standardization test results of the JS code to be tested.

第二配置文件中包括至少一条用于表征待测试JS代码具有的语法不规范问题的语法规范性信息。基于此,可选地,本发明实施例中,第二测试结果获取模块,具体用于:The second configuration file includes at least one piece of grammatical normative information used to characterize grammatical irregularities in the JS code to be tested. Based on this, optionally, in the embodiment of the present invention, the second test result acquisition module is specifically used for:

针对每条语法规范性信息,判断待测试JS代码中是否存在与语法规范性信息对应的语法设置;For each piece of grammatical normative information, determine whether there is a grammatical setting corresponding to the grammatical normative information in the JS code to be tested;

若待测试JS代码中存在与语法规范性信息对应的语法设置,则将语法设置作为不规范语法;If there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting will be regarded as non-standard grammar;

若JS代码中存在不规范语法,则确定待测试JS代码的代码语法规范性测试结果为不规范,否则,确定待测试JS代码的代码语法规范性测试结果为规范。If there is irregular syntax in the JS code, it is determined that the code syntax normative test result of the JS code to be tested is irregular; otherwise, the code syntax normative test result of the JS code to be tested is determined to be normative.

可选地,本发明实施例中,第二测试结果获取模块,又具体用于:Optionally, in the embodiment of the present invention, the second test result acquisition module is specifically used for:

基于预设语法规范性情况,确定语法规范性信息的不规范类型,不规范类型包括第一不规范类型和第二不规范类型,第一不规范类型用于表征语法规范性信息的语法不规范问题为完全不规范,第二不规范类型用于表征语法规范性信息的不规范问题为不完全规范;Based on the preset grammatical normative situation, the irregularity type of the grammatical normative information is determined. The irregularity type includes the first irregularity type and the second irregularity type. The first irregularity type is used to characterize the grammatical irregularity of the grammatical normative information. The question is completely irregular, and the second type of irregularity used to represent grammatical normative information is incompletely standardized;

若语法规范性信息的不规范类型为第一不规范类型,则将语法设置作为完全不规范语法;If the irregularity type of the grammar normative information is the first irregularity type, the grammar is set as a completely irregular grammar;

若所述语法规范性信息的不规范类型为所述第二不规范类型,则将语法设置作为完全不完全规范语法。If the irregularity type of the grammar normative information is the second irregularity type, the grammar is set as a completely incomplete normative grammar.

关于第二测试结果获取模块114的描述具体可参考上述步骤S400的详细描述,也即,步骤S400可以由第二测试结果获取模块114执行,此处不再赘述。For a description of the second test result acquisition module 114, reference may be made to the detailed description of the above step S400. That is, step S400 may be executed by the second test result acquisition module 114, and will not be described again here.

综上,本发明实施例提供的JS代码测试方法、装置及电子设备能够获取待测试JS代码,以及与待测试JS代码对应的第一配置文件,并基于第一配置文件同时测试待测试JS代码相对于预设浏览器集合的兼容性,获得待测试JS代码的代码兼容性测试结果。如此,在需要对待测试JS代码进行测试时,只需基于第一配置文件就可以直接同时测试待测试JS代码相对于预设浏览器集合的兼容性,从而获得待测试JS代码的代码兼容性测试结果,因此,相较于现有技术中,通过人工测试的方式分别测试每个浏览器对待测试JS代码的兼容性的方案而言,测试效率有了较大程度的提高。In summary, the JS code testing method, device and electronic equipment provided by the embodiments of the present invention can obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested, and simultaneously test the JS code to be tested based on the first configuration file Relative to the compatibility of the preset browser set, obtain the code compatibility test results of the JS code to be tested. In this way, when the JS code to be tested needs to be tested, the compatibility of the JS code to be tested with respect to the preset browser collection can be directly and simultaneously tested based on the first configuration file, thereby obtaining a code compatibility test of the JS code to be tested. As a result, compared with the existing technology that separately tests the compatibility of each browser with the JS code to be tested through manual testing, the testing efficiency is greatly improved.

在本发明实施例所提供的几个实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置和方法实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本公开的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。In the several embodiments provided by the embodiments of the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device and method embodiments described above are only illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show possible implementation architectures of the devices, methods and computer program products according to multiple embodiments of the present disclosure. Functionality and operation. In this regard, each block in the flowchart or block diagram may represent a module, segment, or portion of code that contains one or more executable functions for implementing the specified logical function instruction. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two consecutive blocks may actually execute substantially in parallel, or they may sometimes execute in the reverse order, depending on the functionality involved. It will also be noted that each block of the block diagram and/or flowchart illustration, and combinations of blocks in the block diagram and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts. , or can be implemented using a combination of specialized hardware and computer instructions.

另外,在本公开各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独包括,也可以两个或两个以上模块集成形成一个独立的部分。In addition, each functional module in various embodiments of the present disclosure can be integrated together to form an independent part, each module can be included separately, or two or more modules can be integrated to form an independent part.

功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,电子设备,或者网络设备等)执行本公开各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,RandomAccess Memory)、磁碟或者光盘等各种可以存储程序代码的介质。需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还包括另外的相同要素。If functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present disclosure. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code. It should be noted that, as used herein, the terms "include", "comprises" or any other variation thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or device that includes a series of elements not only includes those elements, It also includes other elements not expressly listed or inherent in the process, method, article or equipment. Without further limitation, an element qualified by the statement "comprises a..." does not preclude the inclusion of additional identical elements in the process, method, article, or apparatus that includes the element.

以上仅为本公开的可选实施例而已,并不用于限制本公开,对于本领域的技术人员来说,本公开可以有各种更改和变化。凡在本公开的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本公开的保护范围之内。The above are only optional embodiments of the present disclosure and are not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and changes. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this disclosure shall be included in the protection scope of this disclosure.

A1.一种JS代码测试方法,其特征在于,包括:A1. A JS code testing method, which is characterized by including:

获取待测试JS代码,以及与所述待测试JS代码对应的第一配置文件;Obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested;

基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果。Based on the first configuration file, the compatibility of the JS code to be tested with respect to a preset browser set is simultaneously tested to obtain a code compatibility test result of the JS code to be tested.

A2.根据权利要求A1所述的JS代码测试方法,其特征在于,所述待测试JS代码中包括至少一个目标JS函数,所述第一配置文件中包括至少一条用于表征JS函数相对于所述预设浏览器集合不兼容的函数兼容性信息;A2. The JS code testing method according to claim A1, characterized in that the JS code to be tested includes at least one target JS function, and the first configuration file includes at least one item used to characterize the JS function relative to the target JS function. Function compatibility information that is incompatible with the default browser set described above;

所述基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果,包括:Simultaneously testing the compatibility of the JS code to be tested with respect to a preset browser set based on the first configuration file and obtaining the code compatibility test results of the JS code to be tested includes:

基于至少一条所述函数兼容性信息,分别确定所述待测试JS代码中的各个目标JS函数相对于所述预设浏览器集合的函数兼容性测试结果;Based on at least one piece of the function compatibility information, respectively determine the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set;

根据所述待测试JS代码中的所有目标JS函数的函数兼容性测试结果,确定所述待测试JS代码的代码兼容性测试结果;Determine the code compatibility test results of the JS code to be tested based on the function compatibility test results of all target JS functions in the JS code to be tested;

其中,若所述待测试JS代码中的所有目标JS函数均相对于所述预设浏览器集合兼容,则将所述待测试JS代码的代码兼容性测试结果确定为兼容,否则,将所述待测试JS代码的代码兼容性测试结果确定为不兼容。Wherein, if all target JS functions in the JS code to be tested are compatible with the preset browser set, the code compatibility test result of the JS code to be tested is determined to be compatible; otherwise, the code compatibility test result of the JS code to be tested is determined to be compatible. The code compatibility test result of the JS code to be tested is determined to be incompatible.

A3.根据权利要求A2所述的JS代码测试方法,其特征在于,所述基于至少一条所述函数兼容性信息,分别确定所述待测试JS代码中的各个目标JS函数相对于所述预设浏览器集合的函数兼容性测试结果,包括:A3. The JS code testing method according to claim A2, characterized in that, based on at least one piece of the function compatibility information, it is determined respectively that each target JS function in the JS code to be tested is relative to the preset Function compatibility test results for the browser collection, including:

针对所述待测试JS代码中的每个目标JS函数,分别判断所述第一配置文件中是否存在与所述目标JS函数对应的函数兼容性信息;For each target JS function in the JS code to be tested, determine whether there is function compatibility information corresponding to the target JS function in the first configuration file;

若所述第一配置文件中存在与所述目标JS函数对应的函数兼容性信息,则根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,否则,将所述目标JS函数的函数兼容性测试结果确定为兼容。If there is function compatibility information corresponding to the target JS function in the first configuration file, the function compatibility test result of the target JS function is determined according to the function compatibility information; otherwise, the function compatibility test result of the target JS function is determined. The function compatibility test result of the target JS function is determined to be compatible.

A4.根据权利要求A3所述的JS代码测试方法,其特征在于,所述函数兼容性信息包括函数标签和与所述函数标签对应的函数内容,每个所述函数标签对应一JS函数,所述函数内容用于表征与所述函数标签对应的JS函数相对于所述预设浏览器集合中的浏览器的兼容性;A4. The JS code testing method according to claim A3, wherein the function compatibility information includes function labels and function content corresponding to the function labels, and each function label corresponds to a JS function, so The function content is used to characterize the compatibility of the JS function corresponding to the function tag with respect to the browsers in the preset browser collection;

所述根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,包括:Determining the function compatibility test result of the target JS function based on the function compatibility information includes:

基于预设信息关联情况,确定所述函数兼容性信息的关联类型,所述关联类型包括第一关联类型和第二关联类型,所述第一关联类型用于表征在所述第一配置文件中不存在与所述函数兼容信息功能关联的函数兼容性信息,所述第二关联类型用于表征在所述第一配置文件中存在与所述函数兼容信息功能关联的函数兼容性信息;Based on the preset information association situation, the association type of the function compatibility information is determined. The association type includes a first association type and a second association type. The first association type is used to characterize the information in the first configuration file. There is no function compatibility information functionally associated with the function compatibility information, and the second association type is used to represent that there is function compatibility information functionally associated with the function compatibility information in the first configuration file;

若所述函数兼容信息的关联类型为所述第一关联类型,则根据所述函数兼容信息,确定所述目标JS函数的所述函数兼容性测试结果;If the association type of the function compatibility information is the first association type, determine the function compatibility test result of the target JS function according to the function compatibility information;

若所述函数兼容信息的关联类型为所述第二关联类型,则根据所述函数兼容信息的函数内容以及与所述函数兼容信息功能关联的函数兼容性信息的函数内容,确定所述目标JS函数的所述函数兼容性测试结果。If the association type of the function compatibility information is the second association type, the target JS is determined based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information. The function compatibility test results for the function.

A5.根据权利要求A4所述的JS代码测试方法,其特征在于,所述根据所述函数兼容信息的函数内容以及与所述函数兼容信息功能关联的函数兼容性信息的函数内容,确定所述目标JS函数的所述函数兼容性测试结果,包括:A5. The JS code testing method according to claim A4, characterized in that the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information are determined. The function compatibility test results of the target JS function include:

根据所述函数兼容信息的函数内容,获得对与所述函数兼容信息对应的JS函数兼容的浏览器,作为第一浏览器;According to the function content of the function compatibility information, a browser compatible with the JS function corresponding to the function compatibility information is obtained as the first browser;

将与所述函数兼容信息功能关联的函数兼容性信息,作为关联函数兼容性信息,并根据所述关联函数兼容性信息的函数内容,获得对与所述关联函数兼容信息对应的JS函数兼容的浏览器,作为第二浏览器;The function compatibility information functionally associated with the function compatibility information is used as the associated function compatibility information, and based on the function content of the associated function compatibility information, a function compatible with the JS function corresponding to the associated function compatibility information is obtained. Browser, as a second browser;

判断所述第一浏览器与所述第二浏览器的集合是否与所述预设浏览器集合相同;Determine whether the set of the first browser and the second browser is the same as the default browser set;

若所述第一浏览器与所述第二浏览器的集合与所述预设浏览器集合相同,则确定所述目标JS函数的所述函数兼容性测试结果为兼容,否则,确定所述目标JS函数的所述函数兼容性测试结果为不兼容。If the set of the first browser and the second browser is the same as the preset browser set, it is determined that the function compatibility test result of the target JS function is compatible; otherwise, it is determined that the target JS function is compatible. The function compatibility test result of the JS function is incompatible.

A6.根据权利要求A4所述的JS代码测试方法,其特征在于,当所述目标JS函数的所述函数兼容性测试结果为不兼容时,所述根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,还包括:A6. The JS code testing method according to claim A4, characterized in that when the function compatibility test result of the target JS function is incompatible, the target is determined based on the function compatibility information. The function compatibility test results of JS functions also include:

基于预设浏览器兼容性情况,确定所述函数兼容性信息的不兼容类型,所述不兼容类型包括第一不兼容类型和第二不兼容类型,所述第一不兼容类型用于表征所述函数兼容性信息的不兼容情况为完全不兼容,所述第二不兼容类型用于表征所述函数兼容性信息的不兼容情况为不完全兼容;Based on the preset browser compatibility situation, the incompatibility type of the function compatibility information is determined. The incompatibility type includes a first incompatibility type and a second incompatibility type. The first incompatibility type is used to characterize the The incompatibility of the function compatibility information is completely incompatible, and the second incompatibility type is used to characterize the incompatibility of the function compatibility information as incomplete compatibility;

若所述函数兼容性信息的不兼容类型为所述第一不兼容类型,则将所述目标JS函数的函数兼容性结果确定为完全不兼容;If the incompatibility type of the function compatibility information is the first incompatibility type, determine the function compatibility result of the target JS function to be completely incompatible;

若所述函数兼容性信息的不兼容类型为所述第二不兼容类型,则所述目标JS函数的函数兼容性结果确定为不完全兼容。If the incompatibility type of the function compatibility information is the second incompatibility type, the function compatibility result of the target JS function is determined to be incompletely compatible.

A7.根据权利要求A1所述的JS代码测试方法,其特征在于,所述JS代码测试方法,还包括:A7. The JS code testing method according to claim A1, characterized in that the JS code testing method further includes:

获取所述待测试JS代码对应的第二配置文件;Obtain the second configuration file corresponding to the JS code to be tested;

基于所述第二配置文件测试所述待测试JS代码的语法规范性,获得所述待测试JS代码的代码语法规范性测试结果。The syntax standardization of the JS code to be tested is tested based on the second configuration file, and the code syntax standardization test result of the JS code to be tested is obtained.

A8.根据权利要求A7所述的JS代码测试方法,其特征在于,所述第二配置文件中包括至少一条用于表征待测试JS代码具有的语法不规范问题的语法规范性信息;A8. The JS code testing method according to claim A7, characterized in that the second configuration file includes at least one piece of grammatical normative information used to characterize the grammatical irregularities of the JS code to be tested;

所述基于所述第二配置文件测试所述待测试JS代码的语法规范性,获得所述待测试JS代码的代码语法规范性测试结果,包括:The method of testing the syntax standardization of the JS code to be tested based on the second configuration file and obtaining the code syntax standardization test results of the JS code to be tested includes:

针对每条所述语法规范性信息,判断所述待测试JS代码中是否存在与所述语法规范性信息对应的语法设置;For each piece of grammatical normative information, determine whether there is a grammatical setting corresponding to the grammatical normative information in the JS code to be tested;

若所述待测试JS代码中存在与所述语法规范性信息对应的语法设置,则将所述语法设置作为不规范语法;If there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is regarded as non-standard grammar;

若所述JS代码中存在所述不规范语法,则确定所述待测试JS代码的代码语法规范性测试结果为不规范,否则,确定所述待测试JS代码的代码语法规范性测试结果为规范。If the non-standard syntax exists in the JS code, it is determined that the code syntax normative test result of the JS code to be tested is non-standard; otherwise, it is determined that the code syntax normative test result of the JS code to be tested is normative. .

A9.根据权利要求A8所述的JS代码测试方法,其特征在于,若所述待测试JS代码中存在与所述语法规范性信息对应的语法设置,则将所述语法设置作为不规范语法,包括:A9. The JS code testing method according to claim A8, characterized in that if there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is regarded as non-standard grammar, include:

基于预设语法规范性情况,确定所述语法规范性信息的不规范类型,所述不规范类型包括第一不规范类型和第二不规范类型,所述第一不规范类型用于表征所述语法规范性信息的语法不规范问题为完全不规范,所述第二不规范类型用于表征所述语法规范性信息的不规范问题为不完全规范;Based on the preset grammatical normative situation, the irregularity type of the grammatical normative information is determined. The irregularity type includes a first irregularity type and a second irregularity type. The first irregularity type is used to characterize the The grammatical irregularities of the grammatical normative information are completely irregular, and the second irregularity type used to characterize the irregularities of the grammatical normative information is incompletely normative;

若所述语法规范性信息的不规范类型为所述第一不规范类型,则将所述语法设置作为完全不规范语法;If the irregularity type of the grammar normative information is the first irregularity type, then the grammar is set as a completely irregular grammar;

若所述语法规范性信息的不规范类型为所述第二不规范类型,则将所述语法设置作为完全不完全规范语法。If the irregularity type of the grammar normative information is the second irregularity type, the grammar is set as a completely incomplete normative grammar.

B10.一种JS代码测试装置,其特征在于,包括:B10. A JS code testing device, which is characterized by including:

第一配置文件获取模块,用于获取待测试JS代码,以及与所述待测试JS代码对应的第一配置文件;The first configuration file acquisition module is used to obtain the JS code to be tested and the first configuration file corresponding to the JS code to be tested;

第一测试结果获取模块,用于基于所述第一配置文件同时测试所述待测试JS代码相对于预设浏览器集合的兼容性,获得所述待测试JS代码的代码兼容性测试结果。The first test result acquisition module is configured to simultaneously test the compatibility of the JS code to be tested with respect to the preset browser collection based on the first configuration file, and obtain the code compatibility test results of the JS code to be tested.

B11.根据权利要求B10所述的JS代码测试装置,其特征在于,所述待测试JS代码中包括至少一个目标JS函数,所述第一配置文件中包括至少一条用于表征JS函数相对于所述预设浏览器集合不兼容的函数兼容性信息;B11. The JS code testing device according to claim B10, wherein the JS code to be tested includes at least one target JS function, and the first configuration file includes at least one item used to characterize the JS function relative to the target JS function. Function compatibility information that is incompatible with the default browser set described above;

所述第一测试结果获取模块,具体用于:The first test result acquisition module is specifically used for:

基于至少一条所述函数兼容性信息,分别确定所述待测试JS代码中的各个目标JS函数相对于所述预设浏览器集合的函数兼容性测试结果;Based on at least one piece of the function compatibility information, respectively determine the function compatibility test results of each target JS function in the JS code to be tested relative to the preset browser set;

根据所述待测试JS代码中的所有目标JS函数的函数兼容性测试结果,确定所述待测试JS代码的代码兼容性测试结果;Determine the code compatibility test results of the JS code to be tested based on the function compatibility test results of all target JS functions in the JS code to be tested;

其中,若所述待测试JS代码中的所有目标JS函数均相对于所述预设浏览器集合兼容,则将所述待测试JS代码的代码兼容性测试结果确定为兼容,否则,将所述待测试JS代码的代码兼容性测试结果确定为不兼容。Wherein, if all target JS functions in the JS code to be tested are compatible with the preset browser set, the code compatibility test result of the JS code to be tested is determined to be compatible; otherwise, the code compatibility test result of the JS code to be tested is determined to be compatible. The code compatibility test result of the JS code to be tested is determined to be incompatible.

B12.根据权利要求B10所述的JS代码测试装置,其特征在于,所述第一测试结果获取模块,又具体用于:B12. The JS code testing device according to claim B10, characterized in that the first test result acquisition module is specifically used for:

针对所述待测试JS代码中的每个目标JS函数,分别判断所述第一配置文件中是否存在与所述目标JS函数对应的函数兼容性信息;For each target JS function in the JS code to be tested, determine whether there is function compatibility information corresponding to the target JS function in the first configuration file;

若所述第一配置文件中存在与所述目标JS函数对应的函数兼容性信息,则根据所述函数兼容性信息确定所述目标JS函数的所述函数兼容性测试结果,否则,将所述目标JS函数的函数兼容性测试结果确定为兼容。If there is function compatibility information corresponding to the target JS function in the first configuration file, the function compatibility test result of the target JS function is determined according to the function compatibility information; otherwise, the function compatibility test result of the target JS function is determined. The function compatibility test result of the target JS function is determined to be compatible.

B13.根据权利要求B12所述的JS代码测试装置,其特征在于,所述函数兼容性信息包括函数标签和与所述函数标签对应的函数内容,每个所述函数标签对应一JS函数,所述函数内容用于表征与所述函数标签对应的JS函数相对于所述预设浏览器集合中的浏览器的兼容性;B13. The JS code testing device according to claim B12, wherein the function compatibility information includes function labels and function content corresponding to the function labels, and each function label corresponds to a JS function, so The function content is used to characterize the compatibility of the JS function corresponding to the function tag with respect to the browsers in the preset browser collection;

所述第一测试结果获取模块,又具体用于:The first test result acquisition module is specifically used for:

基于预设信息关联情况,确定所述函数兼容性信息的关联类型,所述关联类型包括第一关联类型和第二关联类型,所述第一关联类型用于表征在所述第一配置文件中不存在与所述函数兼容信息功能关联的函数兼容性信息,所述第二关联类型用于表征在所述第一配置文件中存在与所述函数兼容信息功能关联的函数兼容性信息;Based on the preset information association situation, the association type of the function compatibility information is determined. The association type includes a first association type and a second association type. The first association type is used to characterize the information in the first configuration file. There is no function compatibility information functionally associated with the function compatibility information, and the second association type is used to represent that there is function compatibility information functionally associated with the function compatibility information in the first configuration file;

若所述函数兼容信息的关联类型为所述第一关联类型,则根据所述函数兼容信息,确定所述目标JS函数的所述函数兼容性测试结果;If the association type of the function compatibility information is the first association type, determine the function compatibility test result of the target JS function according to the function compatibility information;

若所述函数兼容信息的关联类型为所述第二关联类型,则根据所述函数兼容信息的函数内容以及与所述函数兼容信息功能关联的函数兼容性信息的函数内容,确定所述目标JS函数的所述函数兼容性测试结果。If the association type of the function compatibility information is the second association type, the target JS is determined based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information. The function compatibility test results for the function.

B14.根据权利要求B13所述的JS代码测试装置,其特征在于,所述第一测试结果获取模块,又具体用于:B14. The JS code testing device according to claim B13, characterized in that the first test result acquisition module is specifically used for:

根据所述函数兼容信息的函数内容,获得对与所述函数兼容信息对应的JS函数兼容的浏览器,作为第一浏览器;According to the function content of the function compatibility information, a browser compatible with the JS function corresponding to the function compatibility information is obtained as the first browser;

将与所述函数兼容信息功能关联的函数兼容性信息,作为关联函数兼容性信息,并根据所述关联函数兼容性信息的函数内容,获得对与所述关联函数兼容信息对应的JS函数兼容的浏览器,作为第二浏览器;The function compatibility information functionally associated with the function compatibility information is used as the associated function compatibility information, and based on the function content of the associated function compatibility information, a function compatible with the JS function corresponding to the associated function compatibility information is obtained. Browser, as a second browser;

判断所述第一浏览器与所述第二浏览器的集合是否与所述预设浏览器集合相同;Determine whether the set of the first browser and the second browser is the same as the default browser set;

若所述第一浏览器与所述第二浏览器的集合与所述预设浏览器集合相同,则确定所述目标JS函数的所述函数兼容性测试结果为兼容,否则,确定所述目标JS函数的所述函数兼容性测试结果为不兼容。If the set of the first browser and the second browser is the same as the preset browser set, it is determined that the function compatibility test result of the target JS function is compatible; otherwise, it is determined that the target JS function is compatible. The function compatibility test result of the JS function is incompatible.

B15.根据权利要求B13所述的JS代码测试装置,其特征在于,当所述目标JS函数的所述函数兼容性测试结果为不兼容时,所述第一测试结果获取模块,还具体用于:B15. The JS code testing device according to claim B13, characterized in that when the function compatibility test result of the target JS function is incompatible, the first test result acquisition module is also specifically used to :

基于预设浏览器兼容性情况,确定所述函数兼容性信息的不兼容类型,所述不兼容类型包括第一不兼容类型和第二不兼容类型,所述第一不兼容类型用于表征所述函数兼容性信息的不兼容情况为完全不兼容,所述第二不兼容类型用于表征所述函数兼容性信息的不兼容情况为不完全兼容;Based on the preset browser compatibility situation, the incompatibility type of the function compatibility information is determined. The incompatibility type includes a first incompatibility type and a second incompatibility type. The first incompatibility type is used to characterize the The incompatibility of the function compatibility information is completely incompatible, and the second incompatibility type is used to characterize the incompatibility of the function compatibility information as incomplete compatibility;

若所述函数兼容性信息的不兼容类型为所述第一不兼容类型,则将所述目标JS函数的函数兼容性结果确定为完全不兼容;If the incompatibility type of the function compatibility information is the first incompatibility type, determine the function compatibility result of the target JS function to be completely incompatible;

若所述函数兼容性信息的不兼容类型为所述第二不兼容类型,则所述目标JS函数的函数兼容性结果确定为不完全兼容。If the incompatibility type of the function compatibility information is the second incompatibility type, the function compatibility result of the target JS function is determined to be incompletely compatible.

B16.根据权利要求B10所述的JS代码测试装置,其特征在于,所述JS代码测试装置,还包括:B16. The JS code testing device according to claim B10, characterized in that the JS code testing device further includes:

第二配置文件获取模块,用于获取所述待测试JS代码对应的第二配置文件;The second configuration file acquisition module is used to obtain the second configuration file corresponding to the JS code to be tested;

第二测试结果获取模块,用于基于所述第二配置文件测试所述待测试JS代码的语法规范性,获得所述待测试JS代码的代码语法规范性测试结果。The second test result acquisition module is configured to test the syntax standardization of the JS code to be tested based on the second configuration file, and obtain the code syntax standardization test results of the JS code to be tested.

B17.根据权利要求B16所述的JS代码测试装置,其特征在于,所述第二配置文件中包括至少一条用于表征待测试JS代码具有的语法不规范问题的语法规范性信息;B17. The JS code testing device according to claim B16, wherein the second configuration file includes at least one piece of grammatical normative information used to characterize the grammatical irregularities of the JS code to be tested;

所述第二测试结果获取模块,具体用于:The second test result acquisition module is specifically used for:

针对每条所述语法规范性信息,判断所述待测试JS代码中是否存在与所述语法规范性信息对应的语法设置;For each piece of grammatical normative information, determine whether there is a grammatical setting corresponding to the grammatical normative information in the JS code to be tested;

若所述待测试JS代码中存在与所述语法规范性信息对应的语法设置,则将所述语法设置作为不规范语法;If there is a grammar setting corresponding to the grammar normative information in the JS code to be tested, the grammar setting is regarded as non-standard grammar;

若所述JS代码中存在所述不规范语法,则确定所述待测试JS代码的代码语法规范性测试结果为不规范,否则,确定所述待测试JS代码的代码语法规范性测试结果为规范。If the non-standard syntax exists in the JS code, it is determined that the code syntax normative test result of the JS code to be tested is non-standard; otherwise, it is determined that the code syntax normative test result of the JS code to be tested is normative. .

B18.根据权利要求B17所述的JS代码测试装置,其特征在于,所述第二测试结果获取模块,又具体用于:B18. The JS code testing device according to claim B17, characterized in that the second test result acquisition module is specifically used for:

基于预设语法规范性情况,确定所述语法规范性信息的不规范类型,所述不规范类型包括第一不规范类型和第二不规范类型,所述第一不规范类型用于表征所述语法规范性信息的语法不规范问题为完全不规范,所述第二不规范类型用于表征所述语法规范性信息的不规范问题为不完全规范;Based on the preset grammatical normative situation, the irregularity type of the grammatical normative information is determined. The irregularity type includes a first irregularity type and a second irregularity type. The first irregularity type is used to characterize the The grammatical irregularities of the grammatical normative information are completely irregular, and the second irregularity type used to characterize the irregularities of the grammatical normative information is incompletely normative;

若所述语法规范性信息的不规范类型为所述第一不规范类型,则将所述语法设置作为完全不规范语法;If the irregularity type of the grammar normative information is the first irregularity type, then the grammar is set as a completely irregular grammar;

若所述语法规范性信息的不规范类型为所述第二不规范类型,则将所述语法设置作为完全不完全规范语法。If the irregularity type of the grammar normative information is the second irregularity type, the grammar is set as a completely incomplete normative grammar.

C19.一种电子设备,其特征在于,包括处理器、存储器和权利要求B10-B18所述的JS代码测试装置,所述JS代码测试装置包括一个或多个存储于所述存储器并由所述处理器执行的软件功能模块。C19. An electronic device, characterized by comprising a processor, a memory and the JS code testing device of claims B10-B18, the JS code testing device including one or more devices stored in the memory and configured by the Software function modules executed by the processor.

D20.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被执行时,可以实现权利要求A1-A9中任意一项所述的JS代码测试方法。D20. A computer-readable storage medium with a computer program stored thereon, characterized in that when the computer program is executed, the JS code testing method described in any one of claims A1-A9 can be implemented.

Claims (18)

1. The JS code testing method is characterized by comprising the following steps of:
acquiring a JS code to be tested and a first configuration file corresponding to the JS code to be tested;
based on the first configuration file, simultaneously testing the compatibility of the JS codes to be tested relative to a preset browser set, and obtaining a code compatibility test result of the JS codes to be tested;
the to-be-tested JS code comprises at least one target JS function, the first configuration file comprises at least one piece of function compatibility information for representing that the JS function is incompatible with the preset browser set, the function compatibility information comprises function labels and function contents, each function label corresponds to one JS function, and the function contents are used for representing that the JS function corresponding to the function label is compatible or incompatible with a browser in the preset browser set;
The step of simultaneously testing the compatibility of the JS code to be tested relative to a preset browser set based on the first configuration file to obtain a code compatibility test result of the JS code to be tested includes:
based on at least one piece of function compatibility information, respectively determining a function compatibility test result of each target JS function in the JS code to be tested relative to the preset browser set;
determining a code compatibility test result of the JS codes to be tested according to function compatibility test results of all target JS functions in the JS codes to be tested;
and if all the target JS functions in the JS codes to be tested are compatible with the preset browser set, determining that the code compatibility test results of the JS codes to be tested are compatible, otherwise, determining that the code compatibility test results of the JS codes to be tested are incompatible.
2. The JS code testing method of claim 1, wherein the determining, based on at least one piece of the function compatibility information, a function compatibility test result of each target JS function in the JS code to be tested with respect to the preset browser set, includes:
For each target JS function in the JS code to be tested, judging whether function compatibility information corresponding to the target JS function exists in the first configuration file or not respectively;
if the function compatibility information corresponding to the target JS function exists in the first configuration file, determining the function compatibility test result of the target JS function according to the function compatibility information, otherwise, determining the function compatibility test result of the target JS function as compatible.
3. The JS code test method of claim 2, wherein the function compatibility information includes function labels and function content corresponding to the function labels, each function label corresponding to a JS function, the function content being used to characterize compatibility of the JS function corresponding to the function label with respect to a browser in the preset browser set;
the determining the function compatibility test result of the target JS function according to the function compatibility information includes:
determining an association type of the function compatibility information based on a preset information association condition, wherein the association type comprises a first association type and a second association type, the first association type is used for representing that function compatibility information associated with the function compatibility information function does not exist in the first configuration file, and the second association type is used for representing that function compatibility information associated with the function compatibility information function exists in the first configuration file;
If the association type of the function compatibility information is the first association type, determining the function compatibility test result of the target JS function according to the function compatibility information;
and if the association type of the function compatibility information is the second association type, determining the function compatibility test result of the target JS function according to the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information.
4. The JS code test method of claim 3, wherein the determining the function compatibility test result for the target JS function based on the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information includes:
obtaining a browser compatible with a JS function corresponding to the function compatibility information as a first browser according to the function content of the function compatibility information;
the function compatibility information functionally associated with the function compatibility information is used as associated function compatibility information, and a browser compatible with a JS function corresponding to the associated function compatibility information is obtained as a second browser according to the function content of the associated function compatibility information;
Judging whether the set of the first browser and the second browser is the same as the preset browser set or not;
and if the set of the first browser and the second browser is the same as the preset browser set, determining that the function compatibility test result of the target JS function is compatible, otherwise, determining that the function compatibility test result of the target JS function is incompatible.
5. The JS code test method of claim 3, wherein when the function compatibility test result of the target JS function is incompatible, the determining the function compatibility test result of the target JS function from the function compatibility information further includes:
determining an incompatibility type of the function compatibility information based on a preset browser compatibility condition, wherein the incompatibility type comprises a first incompatibility type and a second incompatibility type, the first incompatibility type is used for representing that the incompatibility condition of the function compatibility information is completely incompatibility, and the second incompatibility type is used for representing that the incompatibility condition of the function compatibility information is not completely compatibility;
if the incompatible type of the function compatibility information is the first incompatible type, determining that the function compatibility result of the target JS function is completely incompatible;
And if the incompatible type of the function compatibility information is the second incompatible type, determining that the function compatibility result of the target JS function is not completely compatible.
6. The JS code test method of claim 1, further comprising:
acquiring a second configuration file corresponding to the JS code to be tested;
and testing the grammar standardability of the JS codes to be tested based on the second configuration file, and obtaining a code grammar standardability test result of the JS codes to be tested.
7. The JS code testing method of claim 6, wherein the second configuration file includes at least one piece of grammar normalization information for characterizing a grammar non-normalization problem of the JS code to be tested;
the step of testing the grammar normalization of the JS code to be tested based on the second configuration file to obtain a code grammar normalization test result of the JS code to be tested, including:
judging whether grammar setting corresponding to the grammar normalization information exists in the JS codes to be tested according to each piece of grammar normalization information;
if the JS codes to be tested have grammar setting corresponding to the grammar normalization information, setting the grammar as non-canonical grammar;
If the non-standard grammar exists in the JS codes, determining that the code grammar standardability test result of the JS codes to be tested is non-standard, otherwise, determining that the code grammar standardability test result of the JS codes to be tested is standard.
8. The JS code test method of claim 7, wherein if there is a grammar setting corresponding to the grammar normalization information in the JS code to be tested, then setting the grammar as an unnormalized grammar includes:
determining an irregular type of the grammar normalization information based on a preset grammar normalization condition, wherein the irregular type comprises a first irregular type and a second irregular type, the first irregular type is used for representing that grammar irregular questions of the grammar normalization information are completely irregular, and the second irregular type is used for representing that the irregular questions of the grammar normalization information are incompletely standardized;
if the non-canonical type of the grammar normalization information is the first non-canonical type, setting the grammar as a completely non-canonical grammar;
and if the non-canonical type of the grammar normalization information is the second non-canonical type, setting the grammar as an incomplete canonical grammar.
9. A JS code test device, characterized by:
the device comprises a first configuration file acquisition module, a second configuration file acquisition module and a test module, wherein the first configuration file acquisition module is used for acquiring a JS code to be tested and a first configuration file corresponding to the JS code to be tested;
the first test result obtaining module is used for simultaneously testing the compatibility of the JS codes to be tested relative to a preset browser set based on the first configuration file and obtaining a code compatibility test result of the JS codes to be tested;
the to-be-tested JS code comprises at least one target JS function, the first configuration file comprises at least one piece of function compatibility information for representing that the JS function is incompatible with the preset browser set, the function compatibility information comprises function labels and function contents, each function label corresponds to one JS function, and the function contents are used for representing that the JS function corresponding to the function label is compatible or incompatible with a browser in the preset browser set;
the first test result obtaining module is specifically configured to:
based on at least one piece of function compatibility information, respectively determining a function compatibility test result of each target JS function in the JS code to be tested relative to the preset browser set;
Determining a code compatibility test result of the JS codes to be tested according to function compatibility test results of all target JS functions in the JS codes to be tested;
and if all the target JS functions in the JS codes to be tested are compatible with the preset browser set, determining that the code compatibility test results of the JS codes to be tested are compatible, otherwise, determining that the code compatibility test results of the JS codes to be tested are incompatible.
10. The JS code test device of claim 9, wherein the first test result acquisition module is further specifically configured to:
for each target JS function in the JS code to be tested, judging whether function compatibility information corresponding to the target JS function exists in the first configuration file or not respectively;
if the function compatibility information corresponding to the target JS function exists in the first configuration file, determining the function compatibility test result of the target JS function according to the function compatibility information, otherwise, determining the function compatibility test result of the target JS function as compatible.
11. The JS code test device of claim 10, wherein the function compatibility information includes function labels and function content corresponding to the function labels, each function label corresponding to a JS function, the function content being used to characterize compatibility of the JS function corresponding to the function label with respect to a browser in the preset browser set;
The first test result obtaining module is specifically further configured to:
determining an association type of the function compatibility information based on a preset information association condition, wherein the association type comprises a first association type and a second association type, the first association type is used for representing that function compatibility information associated with the function compatibility information function does not exist in the first configuration file, and the second association type is used for representing that function compatibility information associated with the function compatibility information function exists in the first configuration file;
if the association type of the function compatibility information is the first association type, determining the function compatibility test result of the target JS function according to the function compatibility information;
and if the association type of the function compatibility information is the second association type, determining the function compatibility test result of the target JS function according to the function content of the function compatibility information and the function content of the function compatibility information functionally associated with the function compatibility information.
12. The JS code test device of claim 11, wherein the first test result acquisition module is further specifically configured to:
Obtaining a browser compatible with a JS function corresponding to the function compatibility information as a first browser according to the function content of the function compatibility information;
the function compatibility information functionally associated with the function compatibility information is used as associated function compatibility information, and a browser compatible with a JS function corresponding to the associated function compatibility information is obtained as a second browser according to the function content of the associated function compatibility information;
judging whether the set of the first browser and the second browser is the same as the preset browser set or not;
and if the set of the first browser and the second browser is the same as the preset browser set, determining that the function compatibility test result of the target JS function is compatible, otherwise, determining that the function compatibility test result of the target JS function is incompatible.
13. The JS code test device of claim 11, wherein when the function compatibility test result of the target JS function is incompatible, the first test result acquisition module is further specifically configured to:
determining an incompatibility type of the function compatibility information based on a preset browser compatibility condition, wherein the incompatibility type comprises a first incompatibility type and a second incompatibility type, the first incompatibility type is used for representing that the incompatibility condition of the function compatibility information is completely incompatibility, and the second incompatibility type is used for representing that the incompatibility condition of the function compatibility information is not completely compatibility;
If the incompatible type of the function compatibility information is the first incompatible type, determining that the function compatibility result of the target JS function is completely incompatible;
and if the incompatible type of the function compatibility information is the second incompatible type, determining that the function compatibility result of the target JS function is not completely compatible.
14. The JS code test device of claim 9, further comprising:
the second configuration file acquisition module is used for acquiring a second configuration file corresponding to the JS code to be tested;
and the second test result acquisition module is used for testing the grammar normalization of the JS codes to be tested based on the second configuration file and acquiring a code grammar normalization test result of the JS codes to be tested.
15. The JS code test device of claim 14, wherein the second configuration file includes at least one piece of grammar normalization information for characterizing a grammar non-normalization problem of the JS code to be tested;
the second test result obtaining module is specifically configured to:
judging whether grammar setting corresponding to the grammar normalization information exists in the JS codes to be tested according to each piece of grammar normalization information;
If the JS codes to be tested have grammar setting corresponding to the grammar normalization information, setting the grammar as non-canonical grammar;
if the non-standard grammar exists in the JS codes, determining that the code grammar standardability test result of the JS codes to be tested is non-standard, otherwise, determining that the code grammar standardability test result of the JS codes to be tested is standard.
16. The JS code test device of claim 15, wherein the second test result acquisition module is further specifically configured to:
determining an irregular type of the grammar normalization information based on a preset grammar normalization condition, wherein the irregular type comprises a first irregular type and a second irregular type, the first irregular type is used for representing that grammar irregular questions of the grammar normalization information are completely irregular, and the second irregular type is used for representing that the irregular questions of the grammar normalization information are incompletely standardized;
if the non-canonical type of the grammar normalization information is the first non-canonical type, setting the grammar as a completely non-canonical grammar;
and if the non-canonical type of the grammar normalization information is the second non-canonical type, setting the grammar as an incomplete canonical grammar.
17. An electronic device comprising a processor, a memory, and the JS code testing apparatus of claims 9-16, the JS code testing apparatus including one or more software functional modules stored in the memory and executed by the processor.
18. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the JS code test method of any one of claims 1-8.
CN201811317347.3A 2018-11-06 2018-11-06 JS code testing method and device and electronic equipment Active CN109634844B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811317347.3A CN109634844B (en) 2018-11-06 2018-11-06 JS code testing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811317347.3A CN109634844B (en) 2018-11-06 2018-11-06 JS code testing method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN109634844A CN109634844A (en) 2019-04-16
CN109634844B true CN109634844B (en) 2023-12-22

Family

ID=66067321

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811317347.3A Active CN109634844B (en) 2018-11-06 2018-11-06 JS code testing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN109634844B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112540925B (en) * 2020-12-16 2024-12-10 贝壳技术有限公司 New feature compatibility detection system and method, electronic device and readable storage medium
CN115509575B (en) * 2022-09-25 2025-08-05 方正株式(武汉)科技开发有限公司 Web page batch processing method and system for upgrading browser from IE to Edge

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102054100A (en) * 2010-12-17 2011-05-11 中国科学院计算技术研究所 Static analysis-based method and system for detecting RTL (Resistor Transistor Logic) design errors
CN103164213A (en) * 2011-12-19 2013-06-19 中国移动通信集团四川有限公司 Method, device and system of testing compatibility of Web browser
CN103942137A (en) * 2013-01-23 2014-07-23 腾讯科技(深圳)有限公司 Browser compatibility testing method and device
CN104156307A (en) * 2014-07-03 2014-11-19 安徽景行信息科技有限公司 Browser compatibility detecting method and system
CN107103237A (en) * 2016-02-23 2017-08-29 阿里巴巴集团控股有限公司 A kind of detection method and device of malicious file
CN107133165A (en) * 2017-03-22 2017-09-05 腾讯科技(深圳)有限公司 Browser compatibility detection method and device
CN107729249A (en) * 2017-10-18 2018-02-23 北京奇虎科技有限公司 Browser compatibility method of testing, device, system and electronic equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010013043A1 (en) * 1998-03-12 2001-08-09 Richard J. Wagner System and method for determining browser package and version compatibility of a web document
US20110173589A1 (en) * 2010-01-13 2011-07-14 Microsoft Corporation Cross-Browser Interactivity Testing
US9208054B2 (en) * 2011-02-14 2015-12-08 Fujitsu Limited Web service for automated cross-browser compatibility checking of web applications
US20140201625A1 (en) * 2012-04-24 2014-07-17 Concepts in Data Management, SRL System and method for generating a browser compatible document

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102054100A (en) * 2010-12-17 2011-05-11 中国科学院计算技术研究所 Static analysis-based method and system for detecting RTL (Resistor Transistor Logic) design errors
CN103164213A (en) * 2011-12-19 2013-06-19 中国移动通信集团四川有限公司 Method, device and system of testing compatibility of Web browser
CN103942137A (en) * 2013-01-23 2014-07-23 腾讯科技(深圳)有限公司 Browser compatibility testing method and device
CN104156307A (en) * 2014-07-03 2014-11-19 安徽景行信息科技有限公司 Browser compatibility detecting method and system
CN107103237A (en) * 2016-02-23 2017-08-29 阿里巴巴集团控股有限公司 A kind of detection method and device of malicious file
CN107133165A (en) * 2017-03-22 2017-09-05 腾讯科技(深圳)有限公司 Browser compatibility detection method and device
CN107729249A (en) * 2017-10-18 2018-02-23 北京奇虎科技有限公司 Browser compatibility method of testing, device, system and electronic equipment

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
A Selenium based approach to automatic test script generation for refactoring JavaScript code;Ruifeng Chen等;2013 IEEE/ACIS 12th International Conference on Computer and Information Science (ICIS);第341-346页 *
Chapter 5 - A Framework for Detecting and Diagnosing Configuration Faults in Web Applications;Cyntrica Eaton;Advances in Computers;第85卷;第137-181页 *
基于MVC设计模式的源代码检测平台的设计与实现;王安娜;中国优秀硕士学位论文全文数据库 信息科技辑(第10期);I138-29 *
针对JavaScript浏览器兼容性的变异测试方法;程勇 等;计算机应用;第37卷(第4期);第1143-1148+1173页 *

Also Published As

Publication number Publication date
CN109634844A (en) 2019-04-16

Similar Documents

Publication Publication Date Title
CN108415804B (en) Method for acquiring information, terminal device and computer readable storage medium
CN111708655A (en) Application crash processing method, device and system
CN107729452B (en) Webpage loading method and device, electronic equipment and computer readable storage medium
JP6687761B2 (en) Coupling device, coupling method and coupling program
CN114138244B (en) Model class file automatic generation method, device, storage medium and electronic device
CN109634844B (en) JS code testing method and device and electronic equipment
CN105589805A (en) Method and device for generating code coverage rate report
CN108984328B (en) Stack backtracking method and device
CN111538651A (en) Interface testing method, device, server and storage medium
CN110262948B (en) Page data monitoring method, device and equipment
CN110647562A (en) Data query method and device, electronic equipment and storage medium
CN113238863A (en) Data interaction method, device and system of BMC and BIOS
CN104932910A (en) Method and system for application program interface extension
CN109344082B (en) Method and system for automatically testing register
CN113050921A (en) Webpage conversion method, device, storage medium and computer equipment
CN113297502B (en) Method and device for monitoring and filtering rich text
CN112883088B (en) Data processing method, device, equipment and storage medium
CN108023905A (en) Internet of things application system and method
CN108304186B (en) Method and equipment for executing multiple operations based on synthetic configuration file
CN113934507A (en) Method and device for detecting privacy leakage of jQuery library based on taint mark tracking
CN111857868A (en) Method, device, device and computer-readable storage medium for reading and writing securities data
CN107506299B (en) Code analysis method and terminal equipment
CN104462191A (en) File name altering method and electronic device
CN109358850A (en) The intelligence programming implementation method and device that a kind of pair of system setting is written and read
CN115665547A (en) CameraLink camera configuration method and device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20231128

Address after: Room 03, 2nd Floor, Building A, No. 20 Haitai Avenue, Huayuan Industrial Zone (Huanwai), Binhai New Area, Tianjin, 300450

Applicant after: 3600 Technology Group Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Applicant before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant