Sidebar



en:objects:browser:external_params:set_hardware_info

<

sut_hardware_info

set_hardware_info($hardware Concurrency=-1,$device Memory=-1,$device Pixel Ratio=-1); - set hardware data in the JS engine. Sets navigator (hardwareConcurrency,deviceMemory) (Available from version 7.0.8)

The function accepts parameters as input:

  • $hardwareConcurrency – number of processors (threads) available to the browser
  • $deviceMemory – number of gigabytes of memory available to the browser
  • $devicePixelRatio – screen density (window.devicePixelRatio), available from version 7.0.42

    After testing, the function returns the result of its work to the script :
  • true – successfully set
  • false – failed to set

    PHP example:

    <?php $xhe_host = "127.0.0.1:7018";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> browser->".basename(__FILE__)."</font> <hr>";
     
    //1
    echo "1.Let's set navigaror.hardwareConcurrency and navigaror.deviceMemor:";
    echo $browser->set_hardware_info(5,5,2)."<br>";
     
     
    //2
    echo "2.Go to the browser detection page:";
    echo $browser->navigate("http://whoer.net/")."<br>"; sleep(1);
    $span->click_by_inner_text("Extended", false); sleep(1);
    $div->get_by_inner_text("hardwareConcurrency", true)->focus();
    //show
    echo "window.devicePixelRatio:".$browser->run_java_script("window.devicePixelRatio")." n";
    echo "navigator.hardwareConcurrency:".$browser->run_java_script("navigator.hardwareConcurrency")." n";
    echo "navigator.deviceMemory:".$browser->run_java_script("navigator.deviceMemory")." n";
    sleep(10);
     
     
    //3
    echo "3.Set navigaror.hardwareConcurrency and navigaror.deviceMemory by default:";
    echo $browser->set_hardware_info()."<br>";
     
    //4
    echo "4.Let's go to the browser detection page:";
    echo $browser->navigate("http://whoer.net/")."<br>"; sleep(1);
    $span->click_by_inner_text("Extended", false); sleep(1);
    $div->get_by_inner_text("hardwareConcurrency", true)->focus();
    //show
    echo "window.devicePixelRatio:".$browser->run_java_script("window.devicePixelRatio")." n";
    echo "navigator.hardwareConcurrency:".$browser->run_java_script("navigator.hardwareConcurrency")." n";
    echo "navigator.deviceMemory:".$browser->run_java_script("navigator.deviceMemory")." n";
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7022"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> browser.xxxxxxxxx </font> <hr>")
     
    # 1
    echo("1.Let's set navigaror.hardwareConcurrency and navigaror.deviceMemor:");
    echo(browser.set_hardware_info(5,5), "<br>");
     
    # 2
    echo("2.Let's go to the page for browser detection:")
    echo(browser.navigate("https://browserleaks.com/javascript", false), "<br>")
    sleep(10)
     
    # 3
    echo("3.Let's set navigaror.hardwareConcurrency and navigaror.deviceMemo by default:")
    echo(browser.set_hardware_info(), "<br>")
     
    # 4
    echo("4.Let's go to the page for browser detection:")
    echo(browser.navigate("https://browserleaks.com/javascript", false), "<br>")
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7022";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> browser.set_app_info </font> <hr>");
     
               //1
                echo("1.Let's set navigaror.hardwareConcurrency and navigaror.deviceMemory:");
                echo(browser.set_hardware_info(5,5) + "<br>");
     
               //2
                echo("2.Let's go to the page for browser detection:");
                echo(browser.navigate("https://browserleaks.com/javascript") + "<br>");
                sleep(10);
     
               //3
                echo("3.Set navigaror.hardwareConcurrency and navigaror.deviceMemory by default:");
                echo(browser.set_hardware_info() + "<br>");
     
               //4
                echo("4.Let's go to the page for browser detection:");
                echo(browser.navigate("https://browserleaks.com/javascript") + "<br>");
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7022";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> browser.set_accept_language </font> <hr>");
     
    //1
    echo("1.Let's set navigaror.hardwareConcurrency and navigaror.deviceMemory:");
    echo(browser.set_hardware_info(5,5) + "<br>");
     
    //2
    echo("2.Let's go to the page for browser detection:");
    echo(browser.navigate("https://browserleaks.com/javascript") + "<br>");
    app.sleep(10);
     
    //3
    echo("3.Set navigaror.hardwareConcurrency and navigaror.deviceMemory by default:");
    echo(browser.set_hardware_info() + "<br>");
     
    //4
    echo("4.Let's go to the page for browser detection:");
    echo(browser.navigate("https://browserleaks.com/javascript") + "<br>");
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/browser/external_params/set_hardware_info.txt · Last modified: 2026/08/05 22:32 (external edit)