weolar / miniblink49

a lighter, faster browser kernel of blink to integrate HTML UI in your app. 一个小巧、轻量的浏览器内核,用来取代wke和libcef
Apache License 2.0
7.23k stars 1.09k forks source link

document.getElementsByName can't set value #465

Closed mark-lobanov closed 3 years ago

mark-lobanov commented 3 years ago

Hello

I'm try to call JS code document.getElementsByName("password")[0].value = "strong_password" but when I select the password fileld it's value becomes empty

I use Delphi wrapper https://gitee.com/LangjiApp/Wke4Delphi My code: WB.ExecuteJavascript('document.getElementsByName("password")[0].value = "strong_password"');

function TWkeWebCore.ExecuteJavascript(const js: string): boolean;
var
  newjs: AnsiString;
  r    : jsValue;
  es   : jsExecState;
begin
  result := false;
  newjs  := 'try { ' + js + '; return 1; } catch(err){ return 0;}';
  if Assigned(theWebView) then
  begin
    r  := wkeRunJS(theWebView, PansiChar(ansitoutf8(newjs)));
    es := wkeGlobalExec(theWebView);
    if jsIsNumber(r) then
    begin
      if jsToint(es, r) = 1 then
        result := true;
    end;
  end;
end;

node.dll version 2020.11.25.0

https://user-images.githubusercontent.com/20513479/103277763-687e4e80-49d2-11eb-9d41-23a840dae39f.mp4

test with url: https://auth-preprod.ehealth.gov.ua/sign-in?client_id=9a1269f7-b001-43fb-bc8c-32ca4ce80a36&redirect_uri=https://eh-srv-preprod.mcmed.ua/&scope=capitation_report:read client:read connection:delete connection:read connection:refresh_secret connection:write contract:read contract:write contract_request:approve contract_request:create contract_request:read contract_request:sign contract_request:terminate declaration:read declaration_request:approve declaration_request:read declaration_request:reject declaration_request:write division:activate division:deactivate division:details division:read division:write employee:deactivate employee:details employee:read employee:write employee_request:approve employee_request:read employee_request:reject employee_request:write employee_role:read employee_role:write healthcare_service:read healthcare_service:write legal_entity:read medication_dispense:read medication_request:details otp:read otp:write person:read reimbursement_report:read related_legal_entities:read secret:refresh&email=markl@ukr.net&response_type=code

hd2y commented 3 years ago

I tested it in the browser and the results were the same, so I didn't think there was any problem with Miniblink.

mark-lobanov commented 3 years ago

I replaced my code with WB.ExecuteJavascript('document.forms[0].password.focus();document.forms[0].password.value="strong_password";'); and problem is gone

What's the difference in javascript ?

Here is this HTML-element: зображення

hd2y commented 3 years ago

image You can check on this.

mark-lobanov commented 3 years ago

it's uncritically issue, you can close it thank you