Method, device and electronic device for detecting code compatibility

By matching the target function of the code to be detected with the functions supported by the preset application object, the target application object is directly determined, which solves the problem of low speed and efficiency of code compatibility testing in the existing technology, and achieves more efficient compatibility detection.

CN111797009BActive Publication Date: 2024-10-29DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010577194.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-22
Publication Date
2024-10-29
Estimated Expiration
2040-06-22

AI Technical Summary

Technical Problem

The existing technology needs to test on a real machine or simulator when detecting code compatibility, resulting in low detection speed and efficiency.

Method used

By obtaining the target function of the code to be detected and matching it with the functions supported by the preset application object, the supported target application object is determined to avoid detection on a real machine or simulator.

Benefits of technology

It improves the testing speed and efficiency of code compatibility detection and simplifies the compatibility testing of codes in various application objects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111797009B_ABST
    Figure CN111797009B_ABST
Patent Text Reader

Abstract

The disclosed embodiments disclose a method, device and electronic device for detecting code compatibility. A specific implementation of the method includes: obtaining the code to be detected; determining the target function included in the code to be detected; matching the target function with the first function indicated by the information of the first function obtained in advance, the first function is a function supported by a preset application object, and the information of the first function includes the identifier of the first function and the identifier of the application object supporting the first function; determining the target application object supporting the code to be detected based on the matching result. The efficiency of compatibility testing of the code to be detected can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device and electronic device for detecting code compatibility. Background Art

[0002] During the code development process, due to the diversity of the environment in which the code runs, it is necessary to determine the compatibility of the code on each application object to ensure that the code can be executed normally on each application object. For this kind of detection, it is generally necessary to use a real machine / simulator to actually run the code on a low-version platform and check whether errors occur in the simulator to determine the compatibility of the front-end code on each application object. Summary of the invention

[0003] This disclosure section is provided to introduce concepts in a brief form, which will be described in detail in the detailed description section below. This disclosure section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] Embodiments of the present disclosure provide a method, an apparatus, and an electronic device for detecting code compatibility.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for detecting code compatibility, comprising: obtaining a code to be detected; determining a target function included in the code to be detected; matching the target function with a first function indicated by information of a first function obtained in advance, wherein the first function is a function supported by a preset application object, and the information of the first function includes an identifier of the first function and an identifier of an application object supporting the first function; and determining a target application object that supports the code to be detected based on the matching result.

[0006] In a second aspect, an embodiment of the present disclosure provides a device for detecting code compatibility, comprising: an acquisition unit, for acquiring a code to be detected; a first determination unit, for determining a target function included in the code to be detected; a matching unit, for matching the target function with a first function indicated by information of a first function acquired in advance, wherein the first function is a function supported by a preset application object, and the information of the first function includes an identifier of the first function and an identifier of an application object supporting the first function; and a second determination unit, for determining a target application object supporting the code to be detected based on the matching result.

[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting code compatibility as described in the first aspect.

[0008] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for detecting code compatibility as described in the first aspect.

[0009] The method, device and electronic device for detecting code compatibility provided by the embodiments of the present disclosure obtain the code to be detected; determine the target function included in the code to be detected; match the target function with the first function indicated by the information of the first function obtained in advance, the first function is a function supported by a preset application object, and the information of the first function includes the identifier of the first function and the identifier of the application object supporting the first function; and determine the target application object supporting the code to be detected based on the matching result. By matching the target function included in the code to be detected with the first function supported by the preset application object, the compatibility status of the code to be detected in the application object is determined according to the matching result. Compared with the prior art, the code to be detected needs to be tested on a real machine or a simulator of the application object. The solution provided by this embodiment does not need to be tested on a real machine or a simulator of the application object, which can improve the speed of the compatibility test of the code, and the compatibility test of the code to be detected in each application object is more efficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0011] Figure 1 is a flow chart of an embodiment of a method for detecting code compatibility according to the present disclosure;

[0012] Figure 2 It is a schematic syntax tree structure diagram;

[0013] Figure 3 is a flow chart of another embodiment of a method for detecting code compatibility according to the present disclosure;

[0014] Figure 4 is a structural schematic diagram of an embodiment of an apparatus for detecting code compatibility according to the present disclosure;

[0015] Figure 5 is an exemplary system architecture in which the method for detecting code compatibility according to an embodiment of the present disclosure may be applied;

[0016] Figure 6 It is a schematic diagram of the basic structure of an electronic device provided according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0017] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0018] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0019] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0020] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0021] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0022] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0023] Please refer to Figure 1 , which shows the process of an embodiment of the method for detecting code compatibility according to the present disclosure. Figure 1 The method for detecting code compatibility includes the following steps:

[0024] Step 101, obtaining the code to be detected.

[0025] In this embodiment, the code to be detected may be a code to be executed in a preset application object, and the application object may be various application software or application programs.

[0026] In some application scenarios, the above application object may be a browser.

[0027] When the application object is a browser, the code to be detected may be code to be executed on the browser page, such as code of a Web application embedded in the browser.

[0028] The obtaining of the code to be detected here includes obtaining the code to be detected input by the developer, or obtaining the code to be detected from the specified address for storing the code to be detected input by the user.

[0029] The above code to be detected may be a code written in JavaScript or in other languages.

[0030] JavaScript is a client-side scripting language that runs in the client browser. Each browser has a JavaScript parsing engine. As a scripting language, it does not need to be compiled and can be directly parsed and executed by the browser.

[0031] JavaScript can enhance the interaction between users and HTML pages, control HTML elements, make the page have some dynamic effects, and enhance the user experience.

[0032] Step 102: determine the target function included in the code to be detected.

[0033] After the code to be detected is obtained in step 101, various methods may be used to analyze the code to be detected, thereby determining the target function included in the code to be detected.

[0034] The target function here can be multiple functions included in the code to be detected. When the application object is a browser, the target function can be a calling function triggered by an event. An event-triggered calling function refers to a function that can be called synchronously or asynchronously when an event occurs. As an example, the target function here can be a function that calls a window object, a method calling function, a regular matching function, etc.

[0035] In some optional implementations of this embodiment, the above step 102 may include the following steps:

[0036] First, perform syntax analysis on the code to be detected to determine the syntax tree corresponding to the code to be detected;

[0037] Secondly, the target function included in the code to be detected is determined based on the nodes corresponding to the syntax tree.

[0038] You can use existing syntax analysis tools to perform syntax analysis on the code to be detected, such as esprima, acorn, traceur-compiler and other syntax analysis tools.

[0039] In these optional implementations, the code to be tested can be parsed to obtain an abstract syntax tree of the code to be tested. An abstract syntax tree (AST) is a tree structure corresponding to the syntax of the source code. In other words, the source code of a programming language maps the statements in the source code to each node in the tree by constructing a syntax tree.

[0040] Please refer to Figure 2 , which shows the statement var AST = "is Tree", a schematic abstract syntax tree structure.

[0041] like Figure 2 As shown, the abstract syntax tree has a top-level type attribute "Program" 201. The second-level attribute is "body[]" 202. The second-level attribute corresponds to an array. Each item stored in the Body array is an object, which contains all the description information for the above statement. "type": "VariableDeclaration" 203 describes the type of the statement and is a variable declaration statement. "kind" 204 is the keyword for variable declaration. "declarations[]" 205 is the content array of the declaration. Each item in the content array is an object. "type": "VariableDeclaration" 203, "kind" 204 and "declarations[]" 205 belong to the third-level attributes. "type" 206 describes the type of the statement. It belongs to the next-level attribute included in "declarations[]" 205. That is, the fourth-level attribute of the abstract syntax tree, "id" 207 describes the object of the variable name. "init" 208 is the object that initializes the variable value. "id" 207 and "init" 208 are the next-level attributes of "type" 206.

[0042] From the above analysis, we can see that the program code itself can be mapped into a syntax tree. By analyzing each node of the syntax tree, we can accurately determine whether each node in the program code corresponds to a statement, such as a declaration statement, assignment statement, etc. We can also use the syntax tree to determine whether each node corresponds to the target function.

[0043] Specifically, the above-mentioned determination of the target function included in the code to be detected based on the node corresponding to the syntax tree may include:

[0044] Each node of the syntax tree is traversed, and during the traversal process, it is determined whether each node includes the target function based on preset rules.

[0045] The preset rules here may be the coding standards followed by the code to be detected.

[0046] Taking the code to be detected as a code written in JavaScript as an example, the above preset rule can be the ECMAScript specification. The ECMAScript specification is a script programming language standardized by Ecma International (formerly the European Computer Manufacturers Association) through ECMA-262.

[0047] Here, the above preset specification may include different versions. Different application objects may support different versions.

[0048] For each node, the content of the node may be matched with functions supported by a preset specification, and if the match is successful, the node includes the target function.

[0049] Step 103, matching the target function with the first function indicated by the pre-acquired first function information, where the first function is a function supported by a preset application object, and the first function information includes an identifier of the first function and an identifier of an application object supporting the first function.

[0050] The above-mentioned preset application objects may include but are not limited to office application software, instant messaging application programs, browsers, etc.

[0051] The above-mentioned browsers may include but are not limited to IE browser, Google Chrome, Firefox, Sogou Browser, and 360 Security Browser.

[0052] The preset specification supported by the preset application object may be obtained in advance. Further, a plurality of first functions supported by the application object are determined according to the preset specification.

[0053] The information of the first function may include an identifier of the first function and an identifier of an application object supporting the first function.

[0054] In practice, the identifier of the target function obtained in step 102 may be matched with the identifier of the first function in the information of the first function.

[0055] Step 104: determine the target application object that supports the code to be detected based on the matching result.

[0056] In this embodiment, the target application object may be determined according to the identifier of the application object that supports the first function that successfully matches the target function.

[0057] In some application scenarios, if the implementation code corresponding to the target function is the same as the implementation code corresponding to the first function or implements the same function, it is considered that the target function is successfully matched with the first function.

[0058] In some other application scenarios, if the identifier of the target function obtained in step 102 successfully matches the identifier of the first function in the information of the first function, it is considered that the target function successfully matches the first function.

[0059] In some optional implementations of this embodiment, the number of target functions included in the above-mentioned code to be detected may include more than two.

[0060] In these optional implementations, step 103 may include: matching the target function included in each code to be detected with the first function indicated by each first function information. Further, the above step 104 may include:

[0061] The preset application object corresponding to the first function that successfully matches all the target functions is determined as the target application object.

[0062] Here, the first function may be multiple first functions.

[0063] As a schematic illustration, the preset application object may include an application object A and an application object B. Application object A supports first functions A1 and A2; application object B supports first functions A1, B1, and B2. The function set supported by application objects A and B is {A1, A2, B1, B2}. The target function may be matched with each first function. The identifier of the application object that supports the first function A1 may include the identifier of application object A and the identifier of application object B. The identifier of the application object that supports the first function A2 may include the identifier of application object A. The identifier of the application object that supports the first function B1 may include the identifier of application object B. The identifier of the application object that supports the first function B2 may include the identifier of application object B.

[0064] If the target function included in the code to be detected is A1', the target function A1' can be matched with each first function supported by the preset application object. Taking the successful matching of the target function A1' with the first function A1 as an example, it can be checked that the application objects supporting the first function A1 are application object A and application object B, so that the target application objects can be determined to be application object A and application object B.

[0065] If the target functions included in the code to be detected are A1' and B1', the target functions A1' and B1' can be matched with the first functions supported by the above-mentioned application object A and application object B, respectively. Taking the successful matching of the target functions A1' and B1' with the first functions A1 and B1 as an example, it can be found that the application objects supporting the first function A1 are application objects A and B. The application object supporting the first function B1 is application object B, so it can be determined that the target application object is application object B.

[0066] The method for detecting code compatibility provided in the present embodiment is as follows: obtaining the code to be detected; determining the target function included in the code to be detected; matching the target function with the first function indicated by the information of the first function obtained in advance, wherein the first function is a function supported by a preset application object, and the information of the first function includes the identifier of the first function and the identifier of the application object supporting the first function; and determining the target application object supporting the code to be detected based on the matching result. By matching the target function included in the code to be detected with the first function supported by the preset application object, the compatibility status of the code to be detected in the application object is determined according to the matching result. Compared with the prior art, in which the code to be detected needs to be tested on a real machine or a simulator of the application object, the solution provided in the present embodiment does not need to be tested on a real machine or a simulator of the application object, which can improve the speed of the compatibility test of the code, and the compatibility test of the code to be detected in each application object is more efficient.

[0067] Please refer to Figure 3 , which shows the process of another embodiment of the method for detecting code compatibility according to the present disclosure. Figure 3 The method for detecting code compatibility includes the following steps:

[0068] Step 301, obtaining the code to be detected.

[0069] Step 302: determine the target function included in the code to be detected.

[0070] In this embodiment, steps 301 and 302 can be performed according to Figure 1 Steps 101 and 102 of the illustrated embodiment are performed in a similar manner and are not described in detail here.

[0071] Step 303, matching the target function with the first function indicated by the pre-acquired first function information, the first function being a function supported by a preset application object, the first function information including an identifier of the first function and an identifier of an application object supporting the first function, the preset application object including the first application object.

[0072] The process of matching the target function with the first function in step 303 can be referred to Figure 1 The description of step 103 of the illustrated embodiment is not repeated here.

[0073] Step 304: If each target function included in the code to be detected successfully matches the first function supported by the first application object, the first application object and the second application object corresponding to the first application object are determined as target application objects.

[0074] The second application object is an application object of an updated version of the first application object. Generally, the second application object may be an application object of a higher version of the first application object.

[0075] Taking a browser as an example, a browser may include multiple versions, for example, IE browser may include: Internet Explorer 8, Internet Explorer 9, Internet Explorer 10, Internet Explorer 11 and other versions. Internet Explorer 8 may be the first application object, and Internet Explorer 9, Internet Explorer 10, and Internet Explorer 11 may all be the second application objects. For another example, Internet Explorer 9 may be used as the first application object, and Internet Explorer 10 and Internet Explorer 11 may be used as the second application objects.

[0076] When testing the code to be detected, you can select a lower version of the browser to test the code.

[0077] The first application object here can be an application object with a lower version. Usually, a higher version application object can be compatible with the functions of a lower version application object. If the code to be detected can run on the lower version first application object, it can also run on the higher version application object in theory.

[0078] As an example, browser A, browser C, and browser D are browsers with the same kernel. Browser C is an updated version of browser A, and browser D is an updated version of browser C. That is, the version of browser C is greater than the version of browser A; and browser D is greater than the version of browser C. When performing compatibility testing on the code to be detected, browser A can be selected as the test browser. That is, browser A is used as the first application object.

[0079] In this embodiment, the above step 304 may include: matching the target function included in the code to be detected with each first function supported by the first application object.

[0080] A plurality of first functions supported by the first application object may be predetermined. Then each target function of the code to be detected is matched with each first function. If each target function of the code to be detected successfully matches the first function supported by the first application object, it may be determined that the first application object can support the above code to be detected. Otherwise, the first application object does not support the above code to be detected.

[0081] If it is determined that the first application object supports the code to be detected, the first application object and the second application object corresponding to the first application object may be determined as the target application objects.

[0082] Still taking the above-mentioned browser A, browser C, and browser D as examples for explanation. When testing the compatibility of the code to be detected, use browser A as the first browser. If it is determined that browser A supports the code to be detected, then browser A, browser C, and browser D can be determined as target browsers.

[0083] In some application scenarios, the preset application object may include application objects of different versions at the same time, and the first function may include the first function commonly included in the application objects of different versions, and the first function individually included in the application objects of different versions. Each target function included in the code to be detected may be matched with each of the first functions. The application object of the lowest version in which the supported first function successfully matches the target function included in the code to be detected, and the application object of a version greater than the lowest version, are determined as the target application object.

[0084] The above-mentioned browser A, browser C, and browser D are still used as examples for description.

[0085] The browsers supporting the first functions L1 and L2 may be browser A, browser C, and browser D; the browsers supporting the first function L3 may be browser C and browser D; and the browser supporting the first function L4 may be browser D.

[0086] If the multiple target functions included in the code to be tested are matched successfully with the first functions L1, L2, and L3 respectively, browser C and browser D can be used as target browsers. At the same time, browsers that do not support running the code to be tested can also be determined.

[0087] In these application scenarios, a single test can be performed to simultaneously determine the browsers that can run the code to be tested and the browsers that do not support running the code to be tested, thereby further improving the efficiency of compatibility testing of the code to be tested.

[0088] and Figure 1 Compared with the implementation shown, in this embodiment, a solution of using a lower version of application objects to detect the code to be detected to determine multiple application objects that support the code to be detected can achieve higher efficiency in compatibility detection of the code to be detected.

[0089] Further references Figure 4 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for detecting code compatibility. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0090] like Figure 4 As shown, the apparatus for detecting code compatibility of this embodiment includes: an acquisition unit 401, a first determination unit 402, a matching unit 403 and a second unit 404. The acquisition unit 401 is used to acquire the code to be detected; the first determination unit 402 is used to determine the target function included in the code to be detected; the matching unit 403 is used to match the target function with the first function indicated by the information of the first function acquired in advance, the first function is a function supported by a preset application object, and the information of the first function includes the identifier of the first function and the identifier of the application object supporting the first function; the second determination unit 404 is used to determine the target application object supporting the code to be detected based on the matching result.

[0091] In this embodiment, the specific processing of the acquisition unit 401, the first determination unit 402, the matching unit 403 and the second unit 404 of the device for detecting code compatibility and the technical effects thereof can be referred to respectively. Figure 1 The relevant descriptions of step 101, step 102, step 103 and step 104 in the corresponding embodiment are not repeated here.

[0092] In some optional implementations of this embodiment, the first determination unit 401 is further used to: perform syntax analysis on the code to be detected to determine a syntax tree corresponding to the code to be detected; and determine a target function included in the code to be detected based on nodes corresponding to the syntax tree.

[0093] In some optional implementations of this embodiment, the number of objective functions is more than two, and the matching unit 403 is further used to: match each first function with each objective function; and the second determination unit 404 is further used to: determine the application object corresponding to the first function that successfully matches all the objective functions as the target application object.

[0094] In some optional implementations of this embodiment, the preset application object includes a first application object, and the second determination unit 404 is further used to: if each target function included in the code to be detected successfully matches the first function supported by the first application object, then determine that the first application object and the second application object corresponding to the first application object are the target application objects; wherein the second application object is an application object of an updated version of the first application object.

[0095] In some optional implementations of this embodiment, the first determining unit 402 is further configured to: traverse each node of the syntax tree, and determine whether each node includes a target function based on a preset specification during the traversal process.

[0096] In some optional implementations of this embodiment, the application object is a browser.

[0097] Please refer to Figure 5 , Figure 5 An exemplary system architecture is shown in which the method for detecting code compatibility according to one embodiment of the present disclosure can be applied.

[0098] like Figure 5 As shown, the system architecture may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0099] The terminal devices 501, 502, and 503 can interact with the server 505 through the network 504 to receive or send messages, etc. Various client applications can be installed on the terminal devices 501, 502, and 503, such as multimedia conference applications, web browser applications, search applications, etc. The client applications in the terminal devices 501, 502, and 503 can receive user instructions and perform corresponding functions according to the user instructions, such as obtaining information for display from the server according to the user instructions.

[0100] Terminal devices 501, 502, 503 can be hardware or software. When terminal devices 501, 502, 503 are hardware, they can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Compression Standard Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4) players, laptop computers and desktop computers, etc. When terminal devices 501, 502, 503 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0101] The server 505 may provide various services, such as detecting a browser application to be displayed on a terminal device.

[0102] It should be noted that the method for detecting code compatibility provided in the embodiment of the present disclosure can be executed by the server 505, and accordingly, the device for detecting code compatibility can be set in the server 505. In addition, the method for detecting code compatibility provided in the embodiment of the present disclosure can also be executed by the terminal devices 501, 502, and 503, and accordingly, the device for detecting code compatibility can be set in the terminal devices 501, 502, and 503.

[0103] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0104] Reference below Figure 6 , which shows an electronic device (eg, Figure 5 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0105] like Figure 6As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0106] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0107] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0108] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0109] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0110] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0111] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains the code to be detected; determines the target function included in the code to be detected; matches the target function with the first function indicated by the information of the first function obtained in advance, the first function is a function supported by a preset application object, and the information of the first function includes the identifier of the first function and the identifier of the application object supporting the first function; and determines the target application object supporting the code to be detected based on the matching result.

[0112] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0113] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0114] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, an acquisition unit may also be described as a "unit for acquiring a code to be detected".

[0115] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0116] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0117] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0118] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0119] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for detecting code compatibility, characterized in that: include: Get the code to be tested; Determine the target function included in the code to be detected; Matching the target function with a first function indicated by pre-acquired information of a first function, where the first function is a function supported by a preset application object, and the information of the first function includes an identifier of the first function and an identifier of an application object supporting the first function; Determine a target application object that supports the code to be detected based on the matching result; The determining of the target function included in the code to be detected includes: Performing grammatical analysis on the code to be detected to determine a grammatical tree corresponding to the code to be detected; Determine the target function included in the code to be detected based on the node corresponding to the syntax tree; The preset application object includes a first application object, and The determining, based on the matching result, a target application object that supports the code to be detected includes: If each target function included in the code to be detected successfully matches the first function supported by the first application object, the first application object and the second application object corresponding to the first application object are determined as target application objects, wherein The second application object is an updated version of the first application object.

2. The method according to claim 1, characterized in that The number of the objective functions is two or more, and The matching of the target function with the first function indicated by the pre-acquired information of the first function includes: matching each target function to a respective first function; and The determining, based on the matching result, a target application object that supports the code to be detected includes: The application object corresponding to the first function that successfully matches all the target functions is determined as the target application object.

3. The method according to claim 1, characterized in that The determining the target function included in the code to be detected based on the node corresponding to the syntax tree includes: Each node of the syntax tree is traversed, and during the traversal process, it is determined whether each node includes a target function based on a preset rule.

4. The method according to any one of claims 1 to 3, characterized in that: The application object is a browser.

5. A device for detecting code compatibility, characterized in that: include: An acquisition unit, used for acquiring a code to be detected; A first determining unit, used to determine the target function included in the code to be detected; a matching unit, configured to match the target function with a first function indicated by pre-acquired information of a first function, where the first function is a function supported by a preset application object, and the information of the first function includes an identifier of the first function and an identifier of an application object supporting the first function; A second determining unit, configured to determine a target application object supporting the code to be detected based on the matching result; The first determining unit is further configured to: Performing grammatical analysis on the code to be detected to determine a grammatical tree corresponding to the code to be detected; Determine the target function included in the code to be detected based on the node corresponding to the syntax tree; The preset application object includes a first application object, and The second determining unit is further configured to: If each target function included in the code to be detected successfully matches the first function supported by the first application object, then determining the first application object and the second application object corresponding to the first application object as the target application object; in The second application object is an updated version of the first application object.

6. The device according to claim 5, characterized in that The number of the objective functions is two or more, and The matching unit is further used for: matching each target function to a respective first function; and The second determining unit is further configured to: The application object corresponding to the first function that successfully matches all the target functions is determined as the target application object.

7. The device according to claim 5, characterized in that The first determining unit is further configured to: Each node of the syntax tree is traversed, and during the traversal process, it is determined whether each node includes a target function based on a preset specification.

8. The device according to any one of claims 5 to 7, characterized in that: The application object is a browser.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Browser compatibility testing method and device

    CN103942137A

  • Compatibility testing method and device

    CN106201850A