Skip to content

Commit

Permalink
aisingapore#376 - upload step update 2 for chrome mode
Browse files Browse the repository at this point in the history
There is likely a change in Chrome Devtools protocol which returns back DOM.attributeModified event messages after DOM.setFileInputFiles method is used in update step. This causes subsequent steps after upload step not to work.

Patch 1 works by filtering and discarding the DOM.attributeModified event messages so that subsequent communication messages with Chrome will continue to work.

Patch 2 works by filtering and discarding DOM. events completely. And also send a DOM.disable call to disable further sending of DOM. event messages.
  • Loading branch information
kensoh committed Apr 4, 2019
1 parent 60fce9c commit 18a3117
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/tagui_chrome.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@
else if (strpos($tagui_intent,'Target.detachFromTarget') !== false) $intent_result_string = trim($client->receive());

// ignore irrelevant DOM.setChildNodes events received when using DOM.querySelector to get NodeId for upload step
// and ignore irrelevant DOM.attributeModified events received after using DOM.setFileInputFiles in upload step
while ((strpos($intent_result_string,"DOM.setChildNodes") !== false) or
(strpos($intent_result_string,"DOM.attributeModified") !== false))
{$intent_result_string = trim($client->receive());}
// and ignore DOM. events received after using DOM.setFileInputFiles in upload step, before DOM.disable kicks in
while (strpos($intent_result_string,'{"method":"DOM.') !== false) {$intent_result_string = trim($client->receive());}

// save intent_result to interface out-file
echo "[tagui] OUTPUT - \n" . "[" . $tagui_count . "] " . $intent_result_string . "\n\n";
Expand Down
2 changes: 2 additions & 0 deletions src/tagui_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ ws_json = JSON.parse(ws_message);
ws_message = chrome_step('DOM.querySelector',{nodeId: ws_json.result.root.nodeId, selector: selector});
ws_json = JSON.parse(ws_message);
ws_message = chrome_step('DOM.setFileInputFiles',{files: [filename], nodeId: ws_json.result.nodeId});
ws_json = JSON.parse(ws_message);
ws_message = chrome_step('DOM.disable'); // disable invoked DOM agent from running and firing events
} catch(e) {casper.echo('ERROR - unable to upload ' + selector + ' as ' + filename);}};

chrome.download = function(url,filename) { // download function for downloading url resource to file
Expand Down
2 changes: 2 additions & 0 deletions src/test/positive_test.signature
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ ws_json = JSON.parse(ws_message);
ws_message = chrome_step('DOM.querySelector',{nodeId: ws_json.result.root.nodeId, selector: selector});
ws_json = JSON.parse(ws_message);
ws_message = chrome_step('DOM.setFileInputFiles',{files: [filename], nodeId: ws_json.result.nodeId});
ws_json = JSON.parse(ws_message);
ws_message = chrome_step('DOM.disable'); // disable invoked DOM agent from running and firing events
} catch(e) {casper.echo('ERROR - unable to upload ' + selector + ' as ' + filename);}};

chrome.download = function(url,filename) { // download function for downloading url resource to file
Expand Down

0 comments on commit 18a3117

Please sign in to comment.