久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

JavaScript 未在 HtmlUnit 中正確執(zhí)行

JavaScript not being properly executed in HtmlUnit(JavaScript 未在 HtmlUnit 中正確執(zhí)行)
本文介紹了JavaScript 未在 HtmlUnit 中正確執(zhí)行的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我目前正在使用 HtmlUnit 開(kāi)發(fā)一些測(cè)試.它正在加載一個(gè)包含 Braintree.js(他們的表單加密庫(kù))的頁(yè)面.我有一堆正在運(yùn)行,但我被困在它稱為加密的地方.有問(wèn)題的JS是:

I'm currently developing some tests with HtmlUnit. It's loading a page that contains braintree.js (their form encryption library). I have a bunch running, but I'm stuck where it calls crypto. The JS in question is:

  (function() {
        try {
            var ab = new Uint32Array(32);
            crypto.getRandomValues(ab);
            sjcl.random.addEntropy(ab, 1024, "crypto.getRandomValues");
        } catch (e) {}
    })();

HtmlUnit 正在拋出:

HtmlUnit is throwing:

EcmaError, ReferenceError, "'crypto' is not defined."

我想 HtmlUnit 不包括加密.是否可以自己包含一個(gè)加密庫(kù)?

I suppose HtmlUnit doesn't include crypto. Would it be possible to include a crypto library myself?

推薦答案

根據(jù)您的評(píng)論,我不得不告訴您,HtmlUnit 在涉及到 JavaScript 時(shí)是一個(gè)令人頭疼的問(wèn)題.它會(huì)抱怨很多沒(méi)有定義的變量和未知的函數(shù)等等.

Based on your comment, I have to tell you that HtmlUnit is a pain in the neck when it comes to JavaScript. It will complain a lot about variables not being defined and unknown functions and so on.

真正的瀏覽器更靈活,例如:它們接受語(yǔ)法不正確的 JavaScript 片段.HtmlUnit 期望一切都是完美的,沒(méi)有任何錯(cuò)誤.此外,即使您沒(méi)有錯(cuò)過(guò)分號(hào),HtmlUnit 也可能會(huì)抱怨.

Real browsers are more flexible, eg: they accept syntactically incorrect pieces of JavaScript. HtmlUnit expects everything to be perfect without any kind of error. Furthermore, even if you didn't miss a semicolon, HtmlUnit might complain.

我的建議:

  • 確保您的 JavaScript 語(yǔ)法正確
  • 避免使用復(fù)雜庫(kù)的用戶(jQuery 似乎得到了適當(dāng)?shù)闹С?
  • 如果您可以使用非最小化版本的庫(kù),那么值得一試
  • 盡量避免使用復(fù)雜的 jQuery 方法(例如:向元素動(dòng)態(tài)添加事件)
  • 還有最重要的一點(diǎn):嘗試在不同的 BrowserVersions 之間切換.事實(shí)證明,Internet Explorer(具有諷刺意味的是)在解釋 JavaScript 時(shí)提供了最佳結(jié)果
  • Make sure your JavaScript is syntactically correct
  • Avoid the user of complex libraries (jQuery seems to be properly supported)
  • If you can use non-minimized versions of libraries it's worth giving it a try
  • Try to avoid complex jQuery methods (eg: adding events dynamically to elements)
  • And the most important one: Try switching between different BrowserVersions. Internet Explorer (ironically) has proven to provide the best results when it comes to interpreting JavaScript

這篇關(guān)于JavaScript 未在 HtmlUnit 中正確執(zhí)行的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Java Remove Duplicates from an Array?(Java從數(shù)組中刪除重復(fù)項(xiàng)?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復(fù)調(diào)用失敗來(lái)自服務(wù)器的意外響應(yīng):在 Android 工作室中未經(jīng)授權(quán))
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯(cuò)誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測(cè)不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 日韩一及片 | 91免费视频 | 久久精品成人 | 夜夜夜久久久 | 欧美日韩综合 | 国产精品免费一区二区三区四区 | 国产精品久久久久久52avav | 欧美性网 | 九色在线观看 | 18成人在线观看 | 精品视频成人 | 性生生活大片免费看视频 | 久久久影院 | 国产网站在线免费观看 | 在线中文一区 | 国产免费一区二区三区免费视频 | 91热在线 | chengrenzaixian | 日韩欧美国产不卡 | 操操日| 成人国产精品一级毛片视频毛片 | 久久se精品一区精品二区 | 9色网站 | 中文字幕亚洲视频 | 日韩和的一区二在线 | 婷婷桃色网 | 99草免费视频 | 不卡一二三区 | 亚洲一级毛片 | 一区二区三区回区在观看免费视频 | 国产精品海角社区在线观看 | 韩国av电影网 | av资源中文在线天堂 | 美女视频黄的免费 | 一区二区三区四区在线 | 天天插天天舔 | 欧美精品第一区 | 色99视频 | 久久一二 | 婷婷一级片 | 日韩国产高清在线观看 |