What is the unit of x and y in canvasrendering2d.moveTo() in canvas of html5?

everyone. I made a different sizes canvas and drew a line with the same values for moveTo() and lineTo() but I get different sized lines.

This is the code.

    function testCanvas(height, width){
    canvas = document.createElement("canvas");
    ctx = canvas.getContext('2d');

    canvas.style.display = "inline-block";
    canvas.style.border = "1px solid black";

    canvas.height = height;
    canvas.width = width;

    document.getElementById("chartContainer").appendChild(canvas);
    }

    function drawLine(x1, y1, x2, y2){
    ctx.beginPath();
    ctx.moveTo(x1,y1);
    ctx.lineTo(x2,y2);
    
    ctx.stroke();
    }
  1. When i go to inspect element > console and call:

     testCanvas(300,300);
     drawLine(10,50,110,50);
    

and

    testCanvas(150,150);
    drawLine(10,50,110,50);

The length of lines is not equal.
Now, if the input for moveTo and lineTo were in pixel unit, these lines would have same length isnt is? What is the default unit here?