Self-driving cars might sound like science fiction, but they are already cruising California's roads and could become sold commercially within the next decade.

Google's fleet of a dozen computer-controlled vehicles — mostly Toyota Priuses equipped with self-driving technology — has logged more than 300,000 miles of self-driving without an accident, the company said.

Autonomous cars use computers, sensors and other technology to operate independently, but a "driver" can override the autopilot function and take control at any time.

With smartphone-wielding drivers more distracted than ever, backers say robotic vehicles have the potential to make roads significantly safer, noting that nearly all car accidents result from human error.

The legislation requires the California Department of Motor Vehicles to draft regulations for autonomous vehicles by Jan. 1, 2015. Currently, state law doesn't mention self-driving cars because the technology is so new.

The regulations would allow vehicles to operate autonomously, but a licensed driver would still need to sit behind the wheel to serve as a backup operator in case of emergency.

The legislation is also aimed at keeping California at the forefront of the autonomous car industry since Stanford University and Silicon Valley companies have been working on the technology for years.

In February, Nevada became the first U.S. state to approve regulations spelling out requirements for companies to test driverless cars on that state's roads.

In recent years, automakers have been introducing autonomous functions such as self-parking, lane departure warnings and adaptive cruise-control, which allows vehicles to automatically accelerate and decelerate with the flow of traffic.

Carmakers such as Audi, BMW, Ford and Volvo have been working on autonomous car technology for years, and experts say commercial vehicles could feature an "autopilot" function within five years.